Two Laptop Bag*
The moose likes Beginning Java and the fly likes How does java -version work without setting path to java\bin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How does java -version work without setting path to java\bin" Watch "How does java -version work without setting path to java\bin" New topic
Author

How does java -version work without setting path to java\bin

Rakesh Rajmohan
Greenhorn

Joined: Jul 09, 2009
Posts: 22
Hello.. When I try compiling my java program using 'Javac' I use to get error "Javac not recognized as...". So I have set the path..

"set path = C:\Program Files\Java\jdk1.5.0_03\bin". So the error stopped.

But when I checked using 'java -version' from command prompt, it worked even before I had set the path as above.

Help me understanding the way it worked. Thanks!!


Cheers,
Rakesh
Kalabaw moo
Ranch Hand

Joined: May 26, 2009
Posts: 61
try this path

Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3426
    
  12
It's running the java.exe in your c:\windows\system32 directory.
This uses the registry to find out the location of your JRE.


Joanne
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Welcome to JavaRanch.

You most likely have a java.exe in your Windows system directory (C:\Windows\System32).
That version of java.exe looks in the Windows registry to find the JRE to execute.

The Windows system directory is in your PATH by default on Windows.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rakesh Rajmohan
Greenhorn

Joined: Jul 09, 2009
Posts: 22
Great.. Can you tell when why is the java.exe present in system32 folder..?

and what I understand from the post is using "java - version" command to find out if the path has been set correctly to java\bin is not the correct way.

So what is the best way to find out if the path has been set correctly.. (I can best type 'set path' in commond prompt and it gives the path info..)

Cheers,
Rakesh
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Probably because besides the JDK you have a JRE installed separately. I think the JRE installation puts java.exe in your Windows system directory.
Kalabaw moo
Ranch Hand

Joined: May 26, 2009
Posts: 61
When JRE is installed the java.exe is included and I was able to try that in one of my laptop it ran the application I created without the jdk. I just typed in java MyApplication
 
 
subject: How does java -version work without setting path to java\bin
 
Similar Threads
Setting environment variables
javac not recognized as an internal or external command
JDK setup
PATH and CLASSPATH
path variable