Reputation:
I face an issue with my application, when compiling it output following message : [ERROR] If you already have installed the JDK, verify your JAVA_HOME environment variable is correctly set.
When i nano ~/.profile
i have this line :
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
and source $JAVA_HOME
outputs :
-bash: source: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home: is a directory
Someone could helps me how to correctly put java jdk on environnement variable ?
My system : MacOs High Sierra version 10.13.6
Upvotes: 2
Views: 1598
Reputation: 201447
Step 1: Modify the JAVA_HOME to stop at the "jdk" root. And add the JAVA_HOME/bin to your PATH. Like,
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
export PATH=$PATH:$JAVA_HOME/bin
Step 2: Source the correct file. After making the two changes above to your ~/.profile
, you do not
source $JAVA_HOME
Instead you
source ~/.profile
Since you're still struggling, I would (as I said in my initial comment), install sdkman!
curl -s "https://get.sdkman.io" | bash
Then you can
sdk use java 11.0.1-open
or
sdk use java 11.0.1-zulu
or
sdk use 8.0.192-zulu
or etc...
sdk ls java
to see available versions. And, sdk ls
will show you a plethora of available java based tools you can install. It's wonderful. It's cross platform. It's free.
Upvotes: 1