Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mac os java version from root is different

Tags:

java

macos

java-7

after installing jdk7u5 for mac os I got different java-versions for "normal" user and root.

java -version gives me the 7.

sudo java -version gives me the 6.

I've looked up in the /System/Library/Frameworks/JavaVM.framework/Versions/ found that there are some links. After I resolved the links to the real Directory I tried it again with the whole path.

/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java -version -> 7

sudo /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java -version -> 6

Same with javac!

Hope you guys could help me!

like image 654
Philipp Schneider Avatar asked Jul 05 '12 13:07

Philipp Schneider


1 Answers

Under OSX /usr/bin/java locates the java version to be used by looking at what you chose using /Applications/Utilities/Java Preferences.app. The files ths uses are also updated by the Oracle updater.

As you have to drag the versions manually to set Java 1.7 you will have only set this for the user you run it as ie not root. To set it for root I ran the app as sudo /Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences and moved 1.7 to the top.

As far as I can see the files the app updates are in ~/Library/Preferences/ByHost/com.apple.java.JavaPreferences.<hex number>.plist where <hex number> is machine related. Root's home directory is /var/root so I now have /var/root/Library/Preferences/ByHost/com.apple.java.JavaPreferences.<hex number>.plist

like image 178
mmmmmm Avatar answered Oct 13 '22 01:10

mmmmmm