Bug 549813 - Selecting JDK installed via SDKMan fails to recognize JVM
Summary: Selecting JDK installed via SDKMan fails to recognize JVM
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.13   Edit
Hardware: PC Mac OS X
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 567590 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-08-06 05:42 EDT by Joseph Ottinger CLA
Modified: 2020-10-06 23:18 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Ottinger CLA 2019-08-06 05:42:21 EDT
Just downloaded Eclipse 2019-06 for OSX. Installed (with the installer), and selected AdoptOpenJDK 11.0.4, installed via SDKman to the default location on OSX, which is:

~/.sdkman/java/candidates/java/11.0.4.hs-adpt

The installer appended /bin to the path, which means the vm argument is pointing to the directory that contains "java" as an executable.

On startup, Eclipse tells me that I need to install Java SE 6, with a dialog box with the text: "To open "Eclipse" you need to install the legacy Java SE 6 runtime. Click "More Info..."

I corrected it by opening eclipse.ini and pointing it to the contents of /usr/libexec/java_home -v 11 (the system JDK 11). I could not get it to run with the SDKMan JVM.
Comment 1 Lorenzo Bettini CLA 2019-10-12 11:31:35 EDT
That's also reported here: https://stackoverflow.com/questions/56686052/sdkman-does-not-work-with-eclipse-app-or-springtoolsuite4-app-on-mac

it looks like you have somehow to trick Eclipse by linking the path of a JDK installation to the path where SDKMAN installs its version...
Comment 2 Lorenzo Bettini CLA 2019-10-12 11:33:59 EDT
By the way, that's even worse if you install Eclipse via Oomph: Oomph lets you select the available JREs in the system (including SDKMAN installations); Oomph then adds the correct -vm argument in eclipse.ini (in case you select the SDKMAN installation, which is different from a JDK system installation) and the installed Eclipse will not start...
Comment 3 Martin D'Aloia CLA 2020-03-22 19:47:23 EDT
After several attempts the only way I found to make Eclipse work with a JDK installed with SDKMAN (or any other JDK that does not have the macOS directory layout [1]) was specifying it on eclipse.ini as: 

-vm
/Users/<YOUR_USER>/.sdkman/candidates/java/current/jre/lib/jli/libjli.dylib

or more generally:

-vm
/<PATH_TO_YOUR_JDK>/jre/lib/jli/libjli.dylib

It's worth to note that the wiki entry explaining how to specify the JVM for macOS [2] does not mention it.


Moreover, it seems that by design the Eclipse launcher uses the macOS JavaVM Framework

  "MacOSX:  The launcher uses the system JavaVM framework and will always load the vm in-process using the JNI invocation API." [3]


Using a JDK with a macOS directory layout (like the macOS .tar.gz version from AdoptOpenJDK) allows us to specify it as:

-vm
/<PATH_TO_YOUR_JDK>/Contents/Home/bin/java


[1] https://medium.com/adoptopenjdk/macos-binary-changes-8293f154c5dc#a322
[2] https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Mac_OS_X_Example
[3] https://help.eclipse.org/2020-03/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Flauncher.html&cp%3D2_1_5_1
[4] https://adoptopenjdk.net/releases.html
Comment 4 Mickael Istria CLA 2020-10-05 08:41:30 EDT
*** Bug 567590 has been marked as a duplicate of this bug. ***
Comment 5 Mickael Istria CLA 2020-10-05 08:48:53 EDT
> It's worth to note that the wiki entry explaining how to specify the JVM for macOS [2] does not mention it.

This wiki is open for edition. Please add the necessary content to that page.
Comment 6 Martin D'Aloia CLA 2020-10-06 23:18:27 EDT
Thanks Mickael! Didn't know that was open for edition to everyone.

I have made some improvements to the macOS section [1]. Feedback or corrections are welcomed.

[1]: https://wiki.eclipse.org/Eclipse.ini#-vm_value:_macOS_Example