15

This is a similar issue to: Eclipse can't find jdk installed with sdkman

I am still facing the issue on Mac (macos-mojave)

Both of my

/usr/bin/java
/usr/bin/javac 

are pointing to

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac

respectively.

SDKMAN! does install the proper java and javac for the SDKMAN!'s default Java version.

Thus, I do have proper java and javac:

% java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

% javac -version
javac 11.0.3

However, I do not have any Java versions installed in:

ls -la /Library/Java/JavaVirtualMachines 
total 0
drwxr-xr-x  2 root  wheel   64 Jun 19 10:06 .
drwxr-xr-x  4 root  wheel  128 Apr 16 06:16 ..

EDIT:

I also tried updating the JVM reference in /Applications/SpringToolSuite4.app/Contents/Eclipse/SpringToolSuite4.ini (comparable to Eclipse.ini):

-vm
/Users/johndoe/.sdkman/candidates/java/current/bin/java
-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.300.v20190213-1655.jar
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.1000.v20190125-2016
-product
org.springframework.boot.ide.branding.sts4
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Xdock:icon=../Resources/sts4.icns

I do get a splash screen for STS, but it still reports no JVMs installed (see screenshots)

SpringToolSuite splash screen Java SE 6 runtime legacy needed

And it seems both Eclipse.app and SpringToolSuite4.app require proper JDK installed traditionally, not using SDKMAN!

I really don't want to install another JDK besides SDKMAN!

Anyone got this to work?

Thanks!

nevenc
  • 524
  • 1
  • 4
  • 10
  • Hi @nevenc, did you find a solution? I am having the same exact issue. – jumping_monkey Oct 19 '19 at 05:13
  • Seems to be that there is no other alternative to-date. In order to run Spring Tool Suite 4(v4.4.0), you need to have the 'traditional' java installed, for my case i installed Java 11 from Oracle (Had to downgrade from Java 13, as Gradle is not ready to run with Java 13). As soon as you have the Java 11 installed, STS will run without any issue(You can check the vm configuration in Installation details). At this point, this is where SDKMAN comes into the picture. You can point your project to any Vendor-Version, installed by SDKMAN. Cheers. – jumping_monkey Oct 20 '19 at 07:16
  • Hey @jumping_monkey unfortunately that’s exactly what I did. Installed one of the older standard JDKs and then updated specific runtimes within STS (eclipse) project. – nevenc Oct 20 '19 at 09:51
  • Hey @nevenc, thanks for your reply. So, it's an "installation issue" with Spring Tool Suite, i hope they will "fix" it one day. Anyway, we have the workaround. Cheers bro. – jumping_monkey Oct 21 '19 at 03:40
  • Hey @nevenc, did you create an issue in Eclipse bugzilla? – Qinto Dec 07 '19 at 10:44
  • 1
    Downloading Oracles JDK is not necessary, I didnt want to login and approve their license agreements. You can download OpenJDK from https://adoptopenjdk.net/ and it will install to `/Library/Java/JavaVirtualMachines`. STS will then start fine and SDKMAN can be used for everything else. – janih May 07 '20 at 12:18

3 Answers3

6

Here is how I got it working [1] on MacOS Catalina.
I had to set the -vm path in my eclipse.ini to:

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

Apparently Eclipse on MacOS always uses JNI invocation to load the VM [2] so I had to make it point to the libjli.dylib instead of the regular java executable.

Links:
[1] Thanks to: https://bugs.eclipse.org/bugs/show_bug.cgi?id=549813
[2] https://help.eclipse.org/2020-03/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Flauncher.html&cp%3D2_1_5_1

Adam
  • 39,529
  • 15
  • 101
  • 139
c5m
  • 61
  • 1
  • 2
  • Had to set it to `/Users//.sdkman/candidates/java/current/lib/jli/libjli.dylib`but it works! – Roland May 27 '20 at 12:23
  • It works. My setup macOS Catalina 10.15.6 and Eclipse Memory Analyzer Version 1.10.0. But for openjdkb 14.0.2 libjli.dylib is located now under lib library (not lib/jli) ~/.sdkman/candidates/java/current/lib/libjli.dylib – moleksyuk Sep 23 '20 at 13:08
  • Worked for JDK 11.0.2 on my macOS Catalina 10.15.7. Thanks – Shahzad Nov 02 '20 at 22:20
4

If the Eclipse launcher cannot find a suitable JVM to run on (which I am assuming is the problem here), you can usually work around this by pointing the 'eclipse.ini' (or 'STS.ini' as the case may be) to the JVM of your choice.

To do this, open the .ini file in a text editor and add two lines at the front of the file. Something like this:

-vm
/usr/lib/jvm/jdk-1.8.0/bin/java
... the rest of the file unchanged...

Note it is important that:

1) these lines are the very first in the file

2) they are on two separate lines (don't try to put both -vm and path of the jvm executable on a single line, it doesn't work).

Kris
  • 3,371
  • 1
  • 18
  • 29
  • I've re-edited the question @Kris. That didn't work unfortunately :( still the same issue! – nevenc Jun 24 '19 at 14:23
  • Okay sorry that didnt't work, this doesn't sound like a typical 'can't find JVM to run Ecipse then and I'm not realy sure how to solve it :-( – Kris Jun 24 '19 at 16:13
  • "these lines are the very first in the file" - this was the key point for me – Jacob Wallace Jan 07 '21 at 03:51
0

I faced this problem on macOS Sierra while trying to use OpenJDK 11.0.2 installed by SDKMAN! in conjunction with Eclipse 2019-06. No other SDKs installed.

macOS consistently seems to refuse launching Eclipse.app for almost all combinations of -vm parameters I supplied in Info.plist and eclipse.ini, except for links to /System/Library/.

Here is my working setup:

  1. I did an sdk default java 11.0.2-open rather than just sdk use. I made sure SDKMAN! symlinked JDK command binaries properly into the /System/Library path:
lrwxr-xr-x  1 root  wheel  75  1 Mai  2017 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Although the symlink destination is not a link anymore, it is the binary that SDKMAN! deployed there. Check it with the -version.

  1. I made sure no <string>-vm</string> parameter is present in Info.plist. All commented out.

  2. My -vm arg in eclipse.ini is:

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

As stated previously, make sure this statement appears before -vmargs.

This finally allows me to launch a recent Eclipse by double-clicking in the Finder or launching the eclipse binary directly. Hope this applies to STS as well.

Good luck.

kay73
  • 1
  • 1
  • 1
    What do you mean by "I made sure SDKMAN! symlinked JDK command binaries properly into the /System/Library path"? Did you manually created the symlink? – lorenzo-bettini Oct 12 '19 at 15:28