Setting VS Code java.home (Mac)

I was following the ScreenSteps guide for installing VS code when I ran into a discrepancy.

My VS code:

Screensteps example:

Running the command results in this error:

Any ideas on what is going on? I could not find any references to setting the value manually.

We’ve been noticing that on some systems that error happens. The manual solution is to go into your vscode settings, and set java.home to youruserfolder/frc2019/jdk. We’re looking into if anything changed in the java extension recently for why this is happening.

1 Like

So I was trying to change it in the settings.json file changing it from “null” to /Users/matthewgleich/frc2019/⁨WPILib_Mac-2019.1.1⁩/jdk,

Is that right?

Every time I try to set my java home, trying various paths, in VS and restart, I get an error message saying folder is missing. I ignored the warning, tried build robot code and received the same error. Below is the java json with the path indicated above and one where it appears the jdk folder is on my MacBook.

{
“java.configuration.updateBuildConfiguration”: “automatic”,
“files.exclude”: {
/.git": true,
"
/.svn”: true,
/.hg": true,
"
/CVS”: true,
“**/.DS_Store”: true,
“bin/”: true,
“.classpath”: true,
“.project”: true
},
“wpilib.online”: true,
“java.home”:"/Users/PaulC$/frc2019/jdk",
}

{
“java.configuration.updateBuildConfiguration”: “automatic”,
“files.exclude”: {
/.git": true,
"
/.svn”: true,
/.hg": true,
"
/CVS”: true,
“**/.DS_Store”: true,
“bin/”: true,
“.classpath”: true,
“.project”: true
},
“wpilib.online”: true,
“java.home”:"/Users/PaulC$/frc2019/WPILib_Mac-2019.1.1/jdk",
}

I know I’m doing something dumb.

If it helps further, this is the first line that appears in the terminal window:

Executing task: ./gradlew build -Dorg.gradle.java.home=“undefined” <

I’m running Mac OS High Sierra and if I do:

echo $JAVA_HOME only a blank line appears. I’ve tried a few things I found through Google to set this; however, nothing sets java home

Do you really have a $ in your user name? I bet that’s screwing things up.

1 Like

Yes that is correct

Ok, when I run/reboot that it doesn’t change it in the settings.json file…

What do you mean? A reboot doesn’t change that setting in the settings file. It would be really bad if it did that.

I mean that it doesn’t apply the changes that it made. It just returns back to “null”…

Thats incredibly bizarre. Do you have any other extensions installed into vscode? Its either that, or some odd mac issue.

Are you sure that there is not a folder in between frc2019 and jdk? For me there is a folder called WPILib_Mac-2019.1.1

I tried my username without the $ - no difference attempting robot build. Read somewhere you needed it.

I removed the Java Pack extension and the java home path from the json file, reloaded - same error when attempting a robot build. I do get Unable to Write Folder Settings because java.home is not a registered configuration when attempting to set the java home to frc home

Right now only Windows PCs can build/deploy code to our test robot using VS. Anyone with a Mac can write code only. We can make it to our competitions this year!

The $ sign will definitely mess up the folder traversal. Have you verified where the jdk directory actually is?

Open a terminal, type cd and press Enter.
Then type this command:

find /Users/PaulC -type d -name jdk

(This assumes that your username is PaulC) . If you’re unsure of your username, open the System Preferences, and look at the Users and Groups applet.

The output of that command will give you an absolute path to your JDK directory. Copy that path, and insert that into the settings.json file for your java.home setting.

I installed the new WPI software and was able to run the ‘Set Java.home to FRC Home’ command!

I have one theme installed but I don’t think it should affect it… I also have a friend with the same problem who doesn’t have any extra packages installed.

Thank you. Just ran into this on my Win10 machine after I did the WPILIB 2.1 update. But it’s all happy now.

Thanks for your amazing support of the FRC community.

-Russ