• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rakesh Rajmohan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this path

 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's running the java.exe in your c:\windows\system32 directory.
This uses the registry to find out the location of your JRE.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rakesh Rajmohan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic