The version of mac os java from root is different

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

java -version gives me 7.

sudo java -version gives me 6.

I looked in and /System/Library/Frameworks/JavaVM.framework/Versions/found that there are some links. After I resolved the links to this 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 thing with javac!

Hope you guys could help me!

+5
source share
3 answers

In OSX / usr / bin / java, a java version is found that will be used by looking at what you have selected using /Applications/Utilities/Java Preferences.app. The use of ths files is also updated by the Oracle updater.

, Java 1.7, , , root. root, sudo /Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences 1.7 .

, ~/Library/Preferences/ByHost/com.apple.java.JavaPreferences.<hex number>.plist, <hex number> . /var/root, /var/root/Library/Preferences/ByHost/com.apple.java.JavaPreferences.<hex number>.plist

+5

Mac OS X 10.7.5 + JRE 1.6.0_43 + JDK 1.7.0_17.

  • java -version = > 1.7
  • sudo java -version = > 1.6

java sudo, :

  • sudo/usr/bin/javaws -viewer
0

It looks like the version of Java used by the link you specified depends on the environment variable JAVA_VERSION. Maybe this variable is configured for your user, but will be cleared sudo? In this case, by explicitly disabling it for the user or setting it as root, you must synchronize them. Of course, you can also replace /A/with the actual version you want to run.

-1
source

All Articles