• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Path  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

This is my confusion about java path. I have been using JDK 1.7 since so many days. I set the path & JAVA_HOME environment variables to run/compile my application in command prompt using java/javac tools. It was working fine. But recently Java 8 update came & I installed JDK 1.8 too without uninstall JDK1.7. It means I have two jdks & jre in my system. I didn't set path for java8. If i execute the "java -version" command in cmd. It shows java1.8 instead of java1.7. How windows using java8 instead of java7 since path variable set to jdk1.7/bin.

My Path values:
C:\Users\vgvenkat>echo %path%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.7.0_17\bin;.


Java Version:
C:\Users\vgvenkat>java -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) Client VM (build 25.0-b70, mixed mode, sharing)


Thanks in advance.
 
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

With Windows, you can run the "where" command to see where the executable was picked up from.

Henry
 
venkatesh goud
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry,

I have checked but it shows jdk1.7 only.

C:\Users\vgvenkat>where java
C:\Windows\System32\java.exe
C:\Program Files\Java\jdk1.7.0_17\bin\java.exe



Thanks,
 
Sheriff
Posts: 4294
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The path C:\Windows\System32\java.exe is first so that java.exe is the one that runs when you just say "java". I have been told that the java.exe in Windows\System32 knows what version to run despite the PATH. If you want to use a java 1.7 version, you will have to execute "C:\Program Files\Java\jdk1.7.0_17\bin\java.exe".
 
Knute Snortum
Sheriff
Posts: 4294
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can use command line flags:

java -version:"1.6"
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:The path C:\Windows\System32\java.exe is first so that java.exe is the one that runs when you just say "java". I have been told that the java.exe in Windows\System32 knows what version to run despite the PATH. If you want to use a java 1.7 version, you will have to execute "C:\Program Files\Java\jdk1.7.0_17\bin\java.exe".


I believe that it is more correct to say that the Java installer replaces the java executable. There is no intelligence (or any sort of setup) to find the latest versioned JVM.

Henry
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:I believe that it is more correct to say that the Java installer replaces the java executable. There is no intelligence (or any sort of setup) to find the latest versioned JVM.

Yes there is. There is an entry in the Windows registry that java.exe uses to find the jvm.dll if it can't find it in a lib subdirectory. If you change the registry entry, the java.exe in the Windows system directory can be made to execute a different JVM.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joanne Neal wrote:
Yes there is. There is an entry in the Windows registry that java.exe uses to find the jvm.dll if it can't find it in a lib subdirectory. If you change the registry entry, the java.exe in the Windows system directory can be made to execute a different JVM.


Interesting. I did not know that...

Thanks,
Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!