Error after migrating to JDK 8 on MAC

After upgrading to JDK 8 on Mac, I get the following error when I try to check my java version. Can anyone help me figure it out?

MAC30880443:Versions t821714$ java -version
Error occurred during initialization of VM
java/lang/ClassNotFoundException: error in opening JAR file <Zip file open error> /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/endorsed/jaxb-api-2.2.12.jar

      

+3


source to share


2 answers


It would seem as if a new JDK has been installed, however your environment variable JAVA_HOME

seems to be either disabled or is still configured to use JDK 7.

To check the current value, you can do echo $JAVA_HOME

To update the value for the current terminal session, you can execute export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

.

If you want the above snippet to run every time you start a new terminal session, you can enter the following which will add it to your .profile



echo "export /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home" >> ~/.profile
. ~/.profile

      

The second line will be the source of this .profile line to load the variables set in it.

Cheers and happy coding.

+3


source


It looks like your java PATH is messed up, setting it depends on the OS version, so take a look here and make sure it's installed correctly.

if you are using os 10+ all you have to do is

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile

      

or if you think you know better than apple and make sure your java_home is by default use:



echo "export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home" >> ~/.bash_profile

      

then do

source ~/.bash_profile

      

also make sure java 8 is installed at the top of your settings. (Utilities -> Java Settings -> General). Click and drag it to the top of the list if it isn't there, otherwise you can continue using the older version of java

+2


source







All Articles