Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325777

Summary: Eclipse JRE/JDK detection on Mac OS X should detect .jdk bundles
Product: [Eclipse Project] JDT Reporter: Mike Swingler <swingler>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, darin.eclipse, heath.borders, markus.kell.r, Michael_Rennie, Mike_Wilson, prakash, pwebster, skovatch
Version: 3.7   
Target Milestone: 3.7 M4   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
sample XML
none
patch
none
updated patch
none
update
none
more updates :-)
none
next
none
Updated patch none

Description Mike Swingler CLA 2010-09-20 13:08:17 EDT
Build Identifier: I20100608-0911

Java for Mac OS X is transitioning to delivering the JDK as a bundle with the .jdk extension. The bundles cause the Contents/Home directory to be opaque and inaccessible to standard file chooser dialogs.

A reasonable workaround (for Mac OS X VMs) would be to configure the dialog to select directories or .jdk "files", and tack on Contents/Home if it's a .jdk bundle.

Ideally, JVM detection can be done by simply running /usr/libexec/java_home -X, which reports all JVMs detected by the OS as an XML plist.

Reproducible: Always

Steps to Reproduce:
1. Install <https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=20703>
2. Launch Eclipse, and open Preferences.
3. Select Java > Installed JREs, and click Add...
4. Choose "Mac OS X VM"
5. Click "Directory..."
6. Attempt to select /Library/Java/JavaVirtualMachines/1.6.0_21-b07-298.jdk/Contents/Home

(it's not possible with the current UI)
Comment 1 Darin Wright CLA 2010-10-21 11:39:24 EDT
*** Bug 328375 has been marked as a duplicate of this bug. ***
Comment 2 Darin Wright CLA 2010-10-22 14:55:03 EDT
Created attachment 181532 [details]
sample XML
Comment 3 Darin Wright CLA 2010-10-27 16:09:11 EDT
Created attachment 181876 [details]
patch

Work in progress to parse XML plist.
Comment 4 Darin Wright CLA 2010-10-27 16:10:30 EDT
Created attachment 181877 [details]
updated patch
Comment 5 Darin Wright CLA 2010-10-28 13:16:06 EDT
Does anyone know if there's a way to tell which JRE is the current/default JRE? (I didn't see anything in the XML).
Comment 6 Mike Swingler CLA 2010-10-28 13:27:53 EDT
(In reply to comment #5)
> Does anyone know if there's a way to tell which JRE is the current/default JRE?
> (I didn't see anything in the XML).

The list is ordered by preference. You should pick the first one that satisfies any criteria you need to match (like version, or architecture). If you have no criteria, it's the first one.
Comment 7 Darin Wright CLA 2010-10-29 12:22:44 EDT
Created attachment 182063 [details]
update
Comment 8 Darin Wright CLA 2010-10-29 13:00:40 EDT
(In reply to comment #6)
> The list is ordered by preference. You should pick the first one that satisfies
> any criteria you need to match (like version, or architecture). If you have no
> criteria, it's the first one.

Thanks. 

Using the new approach (parsing output from java_home -X), I end up with a different number of installed JREs. I.e. on the box I'm testing with, using the new approach I end up with a 1.5 VM and a 1.6 VM. Using the old code, I also get a 1.4 VM. So, is it more correct to use the new approach and not admit to having the 1.4 VM, or why is the 1.4 VM missing from the XML?
Comment 9 Scott Kovatch CLA 2010-10-29 13:11:41 EDT
What version of Mac OS X are you using? I would guess 10.5, since you're finding a 1.5 JVM. The '1.4' JVM was just a symlink that leads to in 1.5. There were applications that hard-linked against libraries in the 1.4 directory, and for backwards compatibility the symlink was necessary so they would continue to run, even when there was no 1.4.2 JVM on the computer.
Comment 10 Mike Swingler CLA 2010-10-29 13:12:58 EDT
(In reply to comment #8)
> Thanks. 
> 
> Using the new approach (parsing output from java_home -X), I end up with a
> different number of installed JREs. I.e. on the box I'm testing with, using the
> new approach I end up with a 1.5 VM and a 1.6 VM. Using the old code, I also
> get a 1.4 VM. So, is it more correct to use the new approach and not admit to
> having the 1.4 VM, or why is the 1.4 VM missing from the XML?

Because it's unchecked in Java Preferences.
Comment 11 Mike Swingler CLA 2010-10-29 13:14:41 EDT
(In reply to comment #9)
> What version of Mac OS X are you using? I would guess 10.5, since you're
> finding a 1.5 JVM. The '1.4' JVM was just a symlink that leads to in 1.5. There
> were applications that hard-linked against libraries in the 1.4 directory, and
> for backwards compatibility the symlink was necessary so they would continue to
> run, even when there was no 1.4.2 JVM on the computer.

Scott, the 1.4 JVM is still there - we just updated it's Info.plist so that it's disabled by default. Update 5 was the last release that shipped 1.4, which is why we require it for any subsequent updates on Leopard.
Comment 12 Scott Kovatch CLA 2010-10-29 13:20:47 EDT
(In reply to comment #11)

> Scott, the 1.4 JVM is still there - we just updated it's Info.plist so that
> it's disabled by default. Update 5 was the last release that shipped 1.4, which
> is why we require it for any subsequent updates on Leopard.

Oh... I thought that update 5 removed it from the system altogether, but it looks like I remembered that wrong. I'll shut up now. :-)
Comment 13 Darin Wright CLA 2010-10-29 14:58:58 EDT
Created attachment 182075 [details]
more updates :-)
Comment 14 Darin Wright CLA 2010-10-29 16:29:23 EDT
Created attachment 182085 [details]
next
Comment 15 Darin Wright CLA 2010-11-09 14:40:21 EST
Created attachment 182757 [details]
Updated patch

This patch maintains installed JRE ID's. This way when using the new search function, an existing JRE installed at from the same location will not be duplicated/replaced by the new JRE (same JRE, but with an updated name as reflected in the plist XML).
Comment 16 Darin Wright CLA 2010-11-09 14:42:25 EST
Fixed. Installed JREs on Mac are now derived from the java_home -X plist. This does not add support for selecting "invisible .jdk" directories. However, that should no longer be required as the plist should contain those JREs. The user can "Search..." to get all installed JREs.
Comment 17 Markus Keller CLA 2012-01-24 09:54:31 EST
Developer Packages that include the src.jar, etc. are currently not easy to install, see bug 369524.