Change java version (Mac)

I have 2 java versions on my computer:

/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 

1.6.0 is set to the default value. How can I get my java programs to run 1.7?

Tried to add:

 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home 

into my .zshrc file. But this only changes the path for my java command.

Also tried to change the HOME symbolic link as follows:

 cd /Library/Java mv Home Home-1.6 ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/ Home 

It had no effect.

Also tried the java changer software: http://www.guigarage.com/2013/02/change-java-version-on-mac-os/ But no effect.

Any idea how to run java programs like .app and .jar files with version 1.7 just by clicking on them?

+7
java java-home macos
source share
3 answers

I believe that OS X (at least 10.8) uses the following paths:

  • JRE: /System/Library/Frameworks/JavaVM.framework/Versions/Current
  • JDK: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

These are symbolic links that you can update by indicating installation 1.7.

You can check this out quite easily:

a) run which java to check which java executable is running. Theoretically, it should be /usr/bin/java .

b) run ls -la in a java executable that should tell you where it points ( /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java on my machine).

I think this should solve your problem with executing .jar . If your Java application is wrapped in .app , I find it somewhat more complex: if memory is used, the version of java used will depend on the JavaApplicationStub used by .app .

+8
source share

You can always add to your profile on Mac or Linux. Just create if the ~ / .profile file does not exist and this line is there:

 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home 

This should work .zshrc, as well as .bash_profile, are loaded only when the terminal window is opened and when the graphical environment starts .

+1
source share
 $ edit ~/.profile #Java 1.8 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home export PATH=${PATH}:${JAVA_HOME} $ java -version java version "1.8.0_20-ea" 

Here are the steps:

http://ukitech.blogspot.com/2014/04/switching-version-of-java-on-mac.html

+1
source share

All Articles