Reputation: 75
I have just installed OpenJDK8 latest version in and changed my default java_home and version in bash, but why the system still shows that I am in openjdk version "1.8.0_152-release"? I don't even know when I installed the 1.8.0_152-release version.
Yilins-Macbook-Pro:~$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
1.8.0_232, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Yilins-Macbook-Pro:~$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Yilins-Macbook-Pro:~$ java -version
openjdk version "1.8.0_152-release"
OpenJDK Runtime Environment (build 1.8.0_152-release-1056-b12)
OpenJDK 64-Bit Server VM (build 25.152-b12, mixed mode)
Update: OK here is the problem. My original path is set to anaconda thus the java version is the one under anaconda.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
# export PATH="/Users/liyilin/anaconda3/bin:$PATH"
But here is another issue regarding path. If I changed the path for JAVA_HOME, my original path for python is no longer useful. Is there a way to make them both exists when operating? Otherwise I need to keep changing back and forth when writing java and python.
Upvotes: 0
Views: 1709
Reputation: 29
Delete the previous version or remove the previous version path from environmental path .
Upvotes: 0
Reputation: 191738
You need to put both things in your path
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
export ANACONDA_HOME="/Users/liyilin/anaconda3"
export PATH="${JAVA_HOME}/bin:${ANACONDA_HOME}/bin:$PATH"
Also, I would suggest using SDKman for Java things and pyenv for python... Both will update your PATH for you and allow you to easily upgrade versions. For example, you should switch to at least Java 11
Homebrew is another option
Upvotes: 2
Reputation: 2178
Run source .bash_profile
to take the changes on .bash_profile to take effect.
Upvotes: 0