Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDKMAN! does not work with Eclipse.app or SpringToolSuite4.app (on Mac)

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!

like image 790
nevenc Avatar asked Jun 20 '19 12:06

nevenc


People also ask

Where does Sdkman install Java Mac?

It should be located in $HOME/. sdkman/candidates/ .

What is sdkman mac?

SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.


1 Answers

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

like image 131
c5m Avatar answered Oct 06 '22 00:10

c5m