This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to invorke java.exe and javac.exe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to invorke java.exe and javac.exe?" Watch "How to invorke java.exe and javac.exe?" New topic
Author

How to invorke java.exe and javac.exe?

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
Why is java.exe can be invoked without setting the path variable But not javac.exe?



Varuna Seneviratna
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3827

Why is java.exe can be invoked without setting the path variable But not javac.exe?


That's interesting . Tell us how did you try it and what you got as the output (any error etc.. ?).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270
    
    8

Also tell us what you get when you invoke java -version


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38519
    
  23
Because many computers have a Java™ Runtime Environment (JRE) installed, including java/java.exe, and the PATH is automatically set up to include that JRE. The JRE doesn't include javac/javac.exe.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3827

Hmm, Yes most branded computers (HP etc..) comes with that. Perhaps OP is having one of those.
Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
The current path is
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Diskeeper Corporation\Diskeeper\;C:\Program Files\Common Files\DivX Shared\


I installed dk1.6.0_14 tha's all what I did

When typed java the result is

C:\>java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)


When typed javac.exe thr redult

isC:\>javac.exe -versuon
'javac.exe' is not recognized as an internal or external command,
operable program or batch file.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38519
    
  23
I still think it is because there is a JRE somewhere in your PATH; it has obviously been updated to 6u14, which is (I believe) the most recent version.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10270
    
    8

Varuna Seneviratna wrote:
I installed dk1.6.0_14 tha's all what I did


Where have you installed your jdk?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

You probably have a java.exe in the C:\Windows\System32 directory. That directory is already in the PATH by default on Windows.

The java.exe in C:\Windows\System32 looks in the Windows registry to see which JRE it should use. It looks at the key \\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion (you can find it with regedit).

The same does not work with javac.exe - you have to put the directory that contains javac.exe in the PATH yourself.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
Installation path is:
C:\Program Files\Java\jdk1.6.0_14


Ritchie:
The path variable does not contain a link to a jre.I have pasted the path variable's links.I did by right clicking and going on My Computer-->Properties-->System Variables--->path, then I copied the variable values.If I do the same and copy and past the path values again

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Diskeeper Corporation\Diskeeper\;C:\Program Files\Common Files\DivX Shared\



Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
Jesper
HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Enviorenment\1.6.0_14 in the 1.6.0_14 folder there are three variables I suppose as




Default REG_SZ (value_not_set)
Java_Home REG_SZ C:\program files\java\jre
Micro_Version REG_SZ 0
RuntimeLib REG_SZ C:\Program Files\Java\jre\client\jvm.dll


The system32 contains a java.exe

This is exactly what you told isn't it?
I am not able to dis[lay as it is!
Thanks For your Help!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to invorke java.exe and javac.exe?