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.
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.
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.