Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339788 - Launcher doesn't work with OpenJDK Java 7 on Mac OS X
Summary: Launcher doesn't work with OpenJDK Java 7 on Mac OS X
Status: CLOSED DUPLICATE of bug 374791
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Launcher (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-12 08:44 EST by James Blackburn CLA
Modified: 2013-09-02 08:18 EDT (History)
28 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Blackburn CLA 2011-03-12 08:44:19 EST
On Eclipse 3.7M6

I've been trying to run eclipse on OpenJDK 7 on Mac OS X.  Unfortunately the launcher doesn't work as it uses: JNI_CreateJavaVM() which isn't yet supported:

http://mail.openjdk.java.net/pipermail/macosx-port-dev/2011-January/000074.html

I've got further(*) by manually running java with all the options on the command line (as outlined at: http://greensopinion.blogspot.com/2009/05/eclipse-35-galileo-on-jdk-7.html).

Given on Linux Eclipse manually execs Java, could this be a fall-back for running Eclipse on Mac OS X too?

Steps to reproduce:
1) Install OpenJDK from: http://code.google.com/p/openjdk-osx-build/downloads/detail?name=OpenJDK-OSX-1.7-universal-20110310.dmg&can=2&q=
2) Open Java Preferences and make JDK 1.7 your default (and disable JDK 1.6)
3) Try to run Eclipse

You get an error: "Alert: Failed to create the Java Virtual Machine"

* You can get further by running java manually on the command line, however this fails due to invalid thread access: 
https://bugs.openjdk.java.net/show_bug.cgi?id=100176
Comment 1 Andrew Overholt CLA 2011-03-14 09:20:28 EDT
IIRC, the launcher only falls back to a separate JVM process on Linux x86_64 but not on x86.
Comment 2 Andrew Niefer CLA 2011-03-15 16:02:20 EDT
I had thought that bug 276763 included changes on mac to fork the vm in a separate process, however looking at the source, we still always use JNI on mac.

bug 288408 is somewhat related
Comment 3 Martin Lippert CLA 2011-10-10 15:57:02 EDT
Tried the launch with the just released JDK 1.7 Developer Preview for Mac OSX, but the issue remains the same...
Comment 4 Konrad Windszus CLA 2011-12-18 06:54:51 EST
According to https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port+Project+Status -> Non-Features JNI instantiation through the JavaVM.framework will not be possible. 
As a workaround it is recommended to embed your own JRE instead.

Also see http://java.net/jira/browse/MACOSX_PORT-98
Comment 5 Brett Wooldridge CLA 2011-12-18 08:35:44 EST
(In reply to comment #4)
> According to
> https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port+Project+Status ->
> Non-Features JNI instantiation through the JavaVM.framework will not be
> possible. 
> As a workaround it is recommended to embed your own JRE instead.
> 
> Also see http://java.net/jira/browse/MACOSX_PORT-98

This seems not quite correct.  There is no need to embed a JRE:

Apps which choose to instantiate Java via JNI, can directly link against the bundle's primary executable, or load the .jdk or .jre via CFBundleCreate(), and access the JNI entry points with CFBundleGetFunctionPointerForName().
Comment 6 Mike Swingler CLA 2012-02-23 10:53:39 EST
Eclipse will be expected to embed it's own JRE/JDK to be as widely deliverable as possible, and to produce apps that also contain an embedded JRE/JDK.

While it may be possible to detect .jdk bundles that may or may not be on the system, the fallback case of forcing the user to install a 3rd-party component is an unacceptable user experience, and cuts off some significant avenues of distribution.
Comment 7 Bruce Campbell CLA 2012-02-23 11:55:59 EST
(In reply to comment #6)
...
Mike Swingler, I agree that eclipse should probably support having an embedded JRE/JDK however,  I otherwise respectfully disagree.  Embedding the JRE/JDK is not the proper solution to this problem.  First, much of the Eclipse user community are developers who are not averse to installing the JDK separately.  Second, any app that wants to share the central JRE/JDK installation will need to detect it's existence, that's the standard modus operandi.  If we want to avoid detecting java then we are saying that anything that needs to run on java will need to embed the JRE - nope, for various reasons.  Third, many Eclipse users will need to have access to multiple JDK versions anyway to be able to target and test against.
Comment 8 Richard Eckart de Castilho CLA 2012-02-26 14:52:24 EST
I like the way that I can select the default Java JRE with the OS X Java configuration tool - having a central default JRE/JDK is good. Eclipse should honor that. At the same time, Eclipse should honor the -vm option in its eclipse.ini (or if necessary in the Info.plist), like on all other platforms, because at times I want to try a different runtime without switching the system default. Again, its good to have a central system-wide place where these other runtimes are kept.
Comment 9 Keith Wedinger CLA 2012-04-29 14:38:04 EDT
This issue also occurs when attempting to start Eclipse 3.7 using the recently released Oracle JDK for OS X.  On my MacBook Pro, I installed the Oracle JDK.  I then opened Java Preferences and made the Oracle JDK the default and disabled the other available JVMs.  When I attempt to start Eclipse, I get an alert box that states, "Failed to create the Java Virtual Machine".  Adding -vm
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java to eclipse.ini does not fix this.
Comment 10 Ian Clarke CLA 2012-04-29 17:44:53 EDT
A discussion of this problem (with the official Oracle 1.7 JDK) and a workaround may be found here: http://stackoverflow.com/questions/10352715/how-do-i-run-eclipse-using-oracles-new-1-7-jdk-for-the-mac/10366339#10366339
Comment 11 Silenio Quarti CLA 2012-05-01 14:25:59 EDT
(In reply to comment #9)
> This issue also occurs when attempting to start Eclipse 3.7 using the recently
> released Oracle JDK for OS X.  On my MacBook Pro, I installed the Oracle JDK. 
> I then opened Java Preferences and made the Oracle JDK the default and disabled
> the other available JVMs.  When I attempt to start Eclipse, I get an alert box
> that states, "Failed to create the Java Virtual Machine".  Adding -vm
> /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java to
> eclipse.ini does not fix this.

This has been fixed in 3.8M7.

Keith, please could you try 3.8M7 with the recently released Oracle JDK for OS X? The work has been done with an earlier update and I want to make sure it still works.

*** This bug has been marked as a duplicate of bug 374791 ***
Comment 12 Keith Wedinger CLA 2012-05-01 14:34:19 EDT
Silenio:  http://download.eclipse.org/eclipse/downloads/eclipse3x.html does not contain a download link for 3.8M7.  The latest build is 3.8M6.  Also, is there 4.2 build that should also contain this fix?
Comment 13 Silenio Quarti CLA 2012-05-01 16:15:53 EDT
3.8M7 has not been declared yet. It should be done by the end of this week.

If you want to try something before, this I-build has the fix:

http://download.eclipse.org/eclipse/downloads/drops/I20120430-2000/
Comment 14 Silenio Quarti CLA 2012-05-01 16:20:04 EDT
One more thing, the latest oracle VM is only 64-bit, so you need the Cocoa/x86_64 build:

http://download.eclipse.org/eclipse/downloads/drops/I20120430-2000/download.php?dropFile=eclipse-SDK-I20120430-2000-macosx-cocoa-x86_64.tar.gz
Comment 15 Daniel Serodio CLA 2012-07-03 14:55:11 EDT
Is this really a duplicate of 374791? That's about bundling a JVM, not running Eclipse with an already-installed JVM... 

Also, the default Java on my Mac is Oracle's 1.7 but by default Eclipse (including 4.2) runs with Apple's 1.6
Comment 16 Silenio Quarti CLA 2012-07-04 09:59:32 EDT
This is not a strict duplicate, but the fix for bug#374791 fixed this problem as well.

Is your Eclipse 32 bit or 64 bit?   The 32 bit Eclipse will not run on the Oracle's JDK because this VM only supports 64 bit.
Comment 17 Konrad Windszus CLA 2012-07-05 08:38:09 EDT
I also have this problem with Lion 10.7.4, Eclipse JEE 4.2 (64-bit) and Java 1.7.0_05 being selected as first choice on my system. Still Eclipse uses Java 6.
Comment 18 Daniel Serodio CLA 2012-07-05 09:57:15 EDT
(In reply to comment #16)
> This is not a strict duplicate, but the fix for bug#374791 fixed this problem
> as well.
> 
> Is your Eclipse 32 bit or 64 bit?   The 32 bit Eclipse will not run on the
> Oracle's JDK because this VM only supports 64 bit.

Eclipse is 64 bit, from the eclipse-jee-juno-macosx-cocoa-x86_64.tar.gz package, and I'm on OS X 10.7.4.

I've added the following lines to eclipse.ini, right before the -vmargs line:

-vm
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Should I comment on bug#374791 instead of here?
Comment 19 Keith Wedinger CLA 2012-07-05 10:18:12 EDT
I am running the classic Eclipse 4.2 on my MacBook Pro with Lion 10.7.4 and my Java Preferences setting is being honored.  Specifically, Eclipse 4.2 is using Oracle JDK 7 which I have marked as the only available JDK.
Comment 20 Konrad Windszus CLA 2012-07-05 12:27:09 EDT
Even if I disable all other Java versions except Java 7 in the Java Preferences Eclipse still uses Java 6 for me.
Comment 21 Daniel Serodio CLA 2012-07-05 14:15:58 EDT
That's weird... I reverted my eclipse.ini to the default, disabled the other VMs, leaving only Java 7 enabled in the Java Preferences, then Eclipse used it.

Then I closed Eclipse, re-enabled the other VMs (leaving Java 7 at the top, as the default) and it still uses Java 7 as expected.

Also, according to Eclipsepedia[1], I had the -vm path wrong (lacking the /bin/java at the end)

[1] http://wiki.eclipse.org/Eclipse.ini#-vm_value:_Mac_OS_X_Example