0

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 I'm pretty sure I have Java installed.

I'm 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?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Does this answer your question? [Find out what JVM Eclipse is running on](https://stackoverflow.com/questions/557169/find-out-what-jvm-eclipse-is-running-on) – pringi Feb 17 '22 at 13:37
  • What says `which java`? Please note, current Eclipse Java IDEs are shipped with an embedded Java 17 (or when using the Eclipse Installer you can choose to install it with or without an embedded Java). – howlger Feb 17 '22 at 13:41
  • which java returns /usr/bin/java while readlink -f $(which java) returns /usr/lib/jvm/jdk-oracle/bin/java i also noted that trying to start a project with eclipse pops the error "Errors occurred during the build. Errors running builder 'Java Builder' on project 'myfirstproject'. For input string: "H" under radix 16" – Marco Montevechi Filho Feb 17 '22 at 14:06
  • @pringi it helps: eclipse.jn points to /usr/bin/java and if i go to /usr/bin and type java -version it tells me its the 17.0.2 However, when i try to start a new project in eclipse its interface seems to point at JavaSE-13 – Marco Montevechi Filho Feb 17 '22 at 14:12

2 Answers2

0

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.

mbooth
  • 96
  • 5
  • It kinda worked: readlink -f $(which java) showed me where is java and there is a default-java symlink. However, inside the symlink there is no folders named "jdk-XX.Y.Z" as in the tutorial. There is only "bin", "conf", etc. Does that mean i have no jdk installed? – Marco Montevechi Filho Feb 17 '22 at 14:00
-1

For Linux try command: readlink -f $(which java)

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.