1

I have a Windows laptop provided by my employer. I don't have admin rights. I was able to download Eclipse for Java and run a very simple program that printed to the console "hello world". However, I'm not able to find the Java files. I used the cmd command java -version and it does not recognize it. I looked in the Local disk > program files, and didn't find Java there either. Can someone explain what is going on?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Jane B.
  • 21
  • 6
  • It would be a good start to find programmatically where is java installed :) https://stackoverflow.com/questions/9006127/find-absolute-java-exe-path-programmatically-from-java-code – Sharad Aug 27 '21 at 16:15
  • 1
    In the run configuration (_Run > Run Configurations..._) there is a button _Show Command Line_. Maybe you do not installed Java on your system, but using the Java that is part of your Eclipse installation. – howlger Aug 27 '21 at 17:01

3 Answers3

1

Long story short: Eclipse has it's own compiler, it does not use the JDK compiler. So it makes perfect sense that Java is not installed but yet you are able to run the code from Eclipse.

SimpleNiko
  • 159
  • 9
  • I see, makes sence. How can I check what version is it using? and would I be able to run more complex code? – Jane B. Aug 27 '21 at 15:56
  • Try to go to eclipse folder and you will see jdk ,java and other files. copy that folder path and run command java -version in a Terminal – Jin Thakur Aug 27 '21 at 16:05
  • Only found this folder "java-2021-06". I runed from that path the java -version command and still didn't work – Jane B. Aug 27 '21 at 16:47
  • opened it from eclipse terminal. All good. Thanks! – Jane B. Aug 27 '21 at 17:00
  • 1
    Sure, Eclipse has its own compiler but a JRE or JDK is needed to run Eclipse (The question was about `java -version`, not `javac -version`). A JDK is required to see the code of system library classes. Some Eclipse IDE packages are shipped with a JDK and in the Eclipse Installer you can choose whether to include Java as part of your Eclipse installation or use a Java installed on your system to run Eclipse. – howlger Aug 27 '21 at 17:07
  • I found that it uses an openjdk version 16. is that the same as a regular JDK? – Jane B. Aug 27 '21 at 17:22
0

You can only use command "java -version" in console if the windows system variable Path contains the "path" to the folder where java is located.

ie:

variable: Path
value: C:\Program Files\Common Files\Oracle\Java\javapath

Go to system properties and look for environment variables.

vrivon
  • 65
  • 8
0

Try to go to eclipse folder and you will see jdk ,java and other files. Copy that java folder path and run command java -version in a Terminal

Jin Thakur
  • 2,711
  • 18
  • 15