Setting VS Code java.home (Mac)


#1

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.


#2

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.


Build Robot code Fails - VS on a Mac
#3

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?


#4

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.


#5

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


#6

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


#7

Yes that is correct


#8

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


#9

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


#10

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


#11

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


#12

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


#13

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!


#14

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.


#15

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


#16

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.


#17

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