Home > Mobile >  I can see java 11 when I am checking version through command prompt but why it's showing java 1
I can see java 11 when I am checking version through command prompt but why it's showing java 1

Time:06-18

its showing below details while checking 'java -version' in CMD

java version "11.0.15" 2022-04-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.15 8-LTS-149) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15 8-LTS-149, mixed mode)

I am getting below response in Eclipse while using 'System.getProperty("java.version")'

Java Version is: 17.0.2

CodePudding user response:

The CMD uses the PATH environment variable to search for executables (java.exe). The executable is searched in the directories listed in that variable, in the given order. The first one found, is the one that is executed.


Eclipse uses its own settings:

  1. the JRE used to start Eclipse can be specified in the eclipse.ini file; if not specified there, the OS default will be used (usually the same as the CMD, see above);

  2. the JRE used to execute an application inside Eclipse, is specified by the Run/Debug configurations (Run-Run Configurations.../Run-Debug Configurations...), the respective project properties (Project-Properties) and Eclipse preferences (Window-Preferences-Java-Installed JREs).

CodePudding user response:

When I chose "Use Default Workspace JRE" inside Java Build Path->JRE System Library it is showing Java 11.0.15 in eclipse

  • Related