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:
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);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