Java Preferences won't start
David DeHaven
david.dehaven at oracle.com
Fri May 17 07:36:01 PDT 2013
>>> Hello,
>>>
>>> My ls -l /Library/Java/JavaVirtualMachines/ looks like this:
>>>
>>> total 0
>>> drwxr-xr-x 3 root wheel 102 Mar 28 2012 1.6.0_31-b04-413.jdk
>>> drwxr-xr-x 3 root wheel 102 Aug 24 2012 jdk1.7.0_06.jdk
>>> drwxr-xr-x 3 root wheel 102 Sep 18 2012 jdk1.7.0_10.jdk
>>> drwxr-xr-x 3 root wheel 102 May 17 15:51 jdk1.8.0.jdk
>>>
>>> All the JDKs are usable when I run commands specifying their full path names. Also, the "default" jdk is the 7u10 one, so that running 'java -version' in the command line will say "1.7.0_10". The 1.8 is b90 installed just now.
>>>
>>> However, when I'm trying to start Java Preferences in order to select the default JDK for the command-line use, I get a small dialog box with an error saying:
>>>
>>> Cannot launch "Java Preferences"
>>> No compatible version of Java 1.5+ is available.
The old /Applications/Utilities/Java Preferences is no longer useful.
>>> After I click Quit, the console output is as follows:
>>>
>>> [JavaAppLauncher] Requested [1.5+], launching in [(null)] instead.
>>> [JavaAppLauncher Error] unable to find a version of Java to launch
>>>
>>> I tried searching this on the Internet but didn't find anything useful.
>>>
>>> I don't even want to run this GUI tool actually. Is there a way to switch the default JDK from command line?
>>
>> Yes.
>>
>> /usr/libexec/java_home
>>
>> See the man pages for java_home at http://www.unix.com/man-page/all/1/java_home/
>
> This tool returns the default value for JAVA_HOME, and in my case it returns the path to the 7u10 JDK. But the java_home can't change the default value. Where does this tool get it from and how do I change it?
There isn't any mechanism to set the order. When you request a specific major version, java_home will give you the latest version it finds. IOW, if you call /usr/libexec/java_home -v 1.7 it would return /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk. Without args it should return the latest major version which is jdk1.8.0.jdk. You'll have to use JAVA_HOME or explicit paths to pick a particular version.
I thought someone had a shell script to use the output of java_home to build a list of JDKs to choose from, then set JAVA_HOME from that... maybe that was just wishful thinking, it doesn't seem like it'd be too difficult to write.
-DrD-
More information about the macosx-port-dev
mailing list