Home > other >  Cant find Java VM to add in Eclipse
Cant find Java VM to add in Eclipse

Time:02-18

I am following a tutorial to learn Java and it uses eclipse. When starting a new java project in the eclipse IDE, after adding the project name the tutorial goes to Configure JREs->Add...->Standard VM and then browses to a folder which seems to be the VM home. However, in the tutorial when the browse window opens, it already opens in a directory which contains all VM folders, named jdk-14, jdk-15, etc.. I cannot by any means find any similar JVM folder in my computer, although im pretty sure i have java installed.

Im running in a Debian 11. if i run

java -version

i get

java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2 8-LTS-86) Java HotSpot(TM) 64-Bit Server VM (build 17.0.2 8-LTS-86, mixed mode, sharing)

Any suggestions on where to look for folders named like jdk-xxx.xx to add to eclipse?

CodePudding user response:

You can find where your Java installation lives with this command:

$ readlink -f $(which java)

On my Fedora Linux workstation it results in:

/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-2.fc35.x86_64/bin/java

So the directory is /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-2.fc35.x86_64

However you will notice that directory has a very specific version in the path. This is undesirable because it will change when java is updated and might break your Eclipse configuration.

But good news: When I look in my /usr/lib/jvm directory there is a versionless symlink on my system which points (eventually) to the same place: /usr/lib/jvm/java-11-openjdk

I would use the versionless symlink because then my Eclipse configuration will not break when java gets updated. Hopefully it is similar on Debian.

CodePudding user response:

If you are in Windows try these steps

Open command prompt and execute c:\> for %i in (java.exe) do @echo. %~$PATH:i

This should print the path of your jdk.

Alternatively if java path is defined try where java in command prompt.

  • Related