20

Im new with sdkman, but I managed to install it and install some software with it: JDK, Gradle and a few others. The problem is that after I downloaded Eclipse and tried to run it, it just simply can't find the JDK. I have already exported JAVA_HOME, and PATH. In fact, I can actually run java, javac and other Java commands from the terminal, I even tried with update-alternatives. I have changed the ownership of the eclipse folder with no results, Eclipse cannot find the JDK.

I had to install java with apt-get and that makes eclipse work, but whats the of using sdkman? So my question is: What configuration am I missing to make Eclipse use the sdkman java installation.

Jacob van Lingen
  • 8,989
  • 7
  • 48
  • 78
Raziel25
  • 405
  • 1
  • 4
  • 13

3 Answers3

29

I faced the same issue and resolved it by creating a symbolic link in /usr/bin for both java and javac.

sudo ln -s ~/.sdkman/candidates/java/current/bin/javac /usr/bin/javac
sudo ln -s ~/.sdkman/candidates/java/current/bin/java /usr/bin/java

I got these locations by doing

which javac
which java
vault
  • 3,930
  • 1
  • 35
  • 46
cmxiv 914
  • 610
  • 6
  • 10
  • 3
    Isn't there a better solution for this? – Arquillian Jun 07 '19 at 08:23
  • I am still facing the same issue on macos-mojave - I posted a new question for it - https://stackoverflow.com/questions/56686052/sdkman-does-not-work-with-eclipse-app-or-springtoolsuite4-app-on-mac – nevenc Jun 20 '19 at 12:31
  • 4
    when I execute the command above, as superuser, it says "Operation not permitted" – hunterino Nov 11 '19 at 16:38
  • $JAVA_HOME still points towards old version (installed with update-alternatives), though `java` and `javac` point towards SDKMAN! candidate now. What can I do to let $JAVA_HOME point towards my SDKMAN! candidate? – philburns May 13 '20 at 09:54
  • This solution work for me while using `dbeaver` with `sdkman`. I am adding this comment because I didn't know where to add absolute path in this given solution - https://askubuntu.com/questions/1014157/dbeaver-with-sdkman-jre-jdk-location. So I have used this one for temporary just work solution. – Visrut Feb 10 '23 at 17:32
4

Locate and edit your eclipse.ini file and change the line right after "-vm" to this:

/home/YOURUSER/.sdkman/candidates/java/current/bin

That should do it for Linux systems. I'm not sure about Windows or Mac tho.

user352472
  • 551
  • 5
  • 17
0

macOS

For macOS you need to set (or add) the -vm argument to your /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini, for example:

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

This is now included (somewhat non-obviously) in the eclipse.ini documentation: https://wiki.eclipse.org/Eclipse.ini#Using_a_JDK_without_macOS_directory_layout

NOTE: Beware that if you use current instead of using a specific JDK version identifier it will use the default if you launch the Eclipse.app using the UI (double-click or using Spotlight). If you launch it from a terminal it will use the one currently selected.

dpdearing
  • 1,726
  • 3
  • 17
  • 21