Trying to test new VS Code support not working

Hello, I have been programming in eclipse for several years now, and have just started to try out vs code since FIRST has decided to support that instead for the future. I followed the setup instructions on the screensteps page, but still receive this error whenever I try to build an example project:

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:compileJava’.
    > Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.

My computer has JDK setup (typing “javac -version” into the command line shows that I hava javac 9.0.1 installed), and I tried to setup the java.home variable, but nothing seems to be working.

Your JAVA_HOME variable should look something like this:

C:\Program Files\Java\jdk-10.0.2

except a jdk 8 installation since that’s what was used for 2018.

I’m not sure if you typo’d in your post, but also make sure the environment variable is titled exactly JAVA_HOME.

Once you’ve verified all these steps, close and reopen VS code so that it inherits the new environment variables.

Setting the Java_Home is going to be a catching point for many. The WPILib team I know is entertaining ways to eliminate this. In the mean time austinshalit gave me these step by steps.

For Windows users:

In the taskbar, search for “Edit the system environment variables”. The top result should open a control panel pane.

At the bottom right of the Window, there is a button called "Environment Variables…

So press the top “New…” button. On the window that appears, give the variable name: “JAVA_HOME”. Then, press “Browse Directory…”. Select the Java directory (C:\Program Files\Java\jdk#.#.#_###)

Press Ok until the windows close. Then restart vscode

It was not recommended to change the java.home variable in the settings.jason file.

Thank you so much! I had no idea that I needed to add JAVA_HOME to the environment variables, I figured that setting the path was sufficient since it works for compiling java code on the computer.

I thought it was ok to set it in the settings.jason too but the only way that worked for me was system variables so that is the way i’m going with.

Sounds like you got it working then?

Just a point… Some schools do not allow student accounts to edit environment variables. (Ours is likely one of them, but I won’t know until we need in a few weeks.)

This could be a particularly annoying sticking point.

Might be a good reason to try out the Alpha. I’ll delete my Environment variable tomorrow and see if I can get the setting.jason edit to work.