install locations for OpenJDK 7...

Mike Swingler swingler at apple.com
Thu Dec 17 12:56:06 PST 2009


On Dec 14, 2009, at 8:07 AM, Ray Kiddy wrote:

> On Dec 13, 2009, at 5:12 PM, Mike Swingler wrote:
> 
>> On Dec 13, 2009, at 4:15 PM, Landon Fuller wrote:
>> 
>>> On Dec 13, 2009, at 4:04 PM, Ray Kiddy wrote:
>>> 
>>>> Is there any interest in packaging the OpenJDK 7 binaries into a real
>>>> Mac OS X-compatible location? One can put them somewhere under /usr
>>>> and make sure that /usr/bin/java points to the right version and this
>>>> is good for server-ish things, but there may be reasons to install the
>>>> OpenJDK 7 binaries under /System/Library/Frameworks/JavaVM.framework/
>>>> Versions/. There is a whole other kind of directory structure under
>>>> there. I believe that if we want to have regular Cocoa applications
>>>> that use java to use the OpenJDK 7 VM, it would have to be installed
>>>> in the JavaVM.framework....
>>> 
>>> It's possible to register a standard VM (installed at any location) with the Mac OS X Java tools such that you can select it as a preferred VM.
>>> 
>>> I'm not sure if this is documented anywhere -- that's something Mike Swingler (CC'd) probably has more information on.
>> 
>> There is primitive support in Mac OS X 10.6 and Java for Mac OS X 10.5 Update 6 to detect 3rd party JVMs installed in ~/Library/Java/JavaVirtualMachines, and /Library/Java/JavaVirtualMachines. The JVM has to be a bundle, with a Contents/Home/bin directory, a primary executable (usually a symlink to libjava.jnilib or libjava.dylib). It also requires an Info.plist similar to the Apple-provided JVMs, but the current OpenJDK should only advertise itself as being able to run command-line, since Applets, Web Start, and double-clickable apps will not work correctly right now.
>> 
>> If you could provide me with a link to built OpenJDK 7 you are using as a reference, I could provide a set of steps to assemble it into a JDK bundle that would be recognized by Java Preferences and the /usr/libexec/java_home machinery.
> 
> Hey Mike -
> 
> Good to hear from you. Thanks for the offer to help. Tell Francois and the guys I said hey.
> 
> So, there are recently updated instructions for building OpenJDK 7 on 10.5 on a wiki page. See:
> 
> 	http://wikis.sun.com/display/OpenJDK/Darwin9Build
> 
> If you go to the BSDPort wiki page, there is a link (external to the wiki) to instructions for building this on Snow Leopard. I have not done the build on 10.6, so I cannot speak to it. But nobody has complained on the mailing list.
> 
> 	http://wikis.sun.com/display/OpenJDK/BSDPort
> 
> I noticed that, in my installed build products, the OpenJDK bin directory does not contain everything, for example, that is in /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands, so there will be some mis-matches to deal with.
> 
> If you want to see what is produced by the build of OpenJDK 7 on 10.5 at this time, I did a "find -ls" in the products directory and that is at http://www.wykiwyk.com/openjdk/openjdk7_ToC.txt.

So I've finally put together some ad-hoc instructions for creating and OpenJDK bundle that will be detectable by the /usr/bin and /usr/libexec/java_home commands:

If you create the following directory:

~/Library/Java/JavaVirtualMachines/

and then create a new bundle directory structure of the form:

OpenJDK 7.jdk/
    Contents/
        Info.plist
        MacOS/
            libjava.dylib -> ../Home/jre/lib/i386/libjava.dylib
        Home/
            <unpacked contents of SoyLatte or OpenJDK7 binary distribution>

with the following Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleIdentifier</key>
	<string>com.example.OpenJDK</string>
	<key>CFBundleExecutable</key>
	<string>libjava.dylib</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>OpenJDK 1.7.0</string>
	<key>CFBundlePackageType</key>
	<string>BNDL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0.0</string>
	<key>CFBundleSignature</key>
	<string>???</string>
	<key>CFBundleVersion</key>
	<string>1.0.0</string>
	<key>JavaVM</key>
	<dict>
		<key>JVMCapabilities</key>
		<array>
			<string>CommandLine</string>
		</array>
		<key>JVMPlatformVersion</key>
		<string>1.7</string>
		<key>JVMVersion</key>
		<string>1.7.0_00</string>
	</dict>
</dict>
</plist>

You can then run:

% `/usr/libexec/java_home -v 1.7`/bin/java -version

And it will execute the new "1.7" version of Java.


Cheers,
Mike Swingler
Java Runtime Engineer
Apple Inc.




More information about the bsd-port-dev mailing list