• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this path

 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
There is no "i" in denial. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic