aspose file tools*
The moose likes Beginning Java and the fly likes Command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Command "java" works, but "javac" does not" Watch "Command "java" works, but "javac" does not" New topic
Author

Command "java" works, but "javac" does not

Alex Pol
Ranch Hand

Joined: Sep 29, 2006
Posts: 33
Hi,

I have installed the J2SE SDK 1.5, the environment variable (user variable) JAVA_HOME is well set to C:\Program Files\Java\jdk1.5.0_08 but the command "javac" does not work. It works only if i am in the bin sub directory of the directory above.

Why is that? The command "java" works !

Thanks.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Perhaps your path variable is pointing to JRE instead ? Can you post the contents of your 'path' system variable ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Vyas
Greenhorn

Joined: May 21, 2007
Posts: 17
true your path variable is pointing to JRE. Or reinstall JSDK
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14111
    
  16

Re-installing the JDK will not help.

Make sure that the 'bin' directory of the JDK is in the PATH. The JDK installation instructions explain how to do this (see step 4).

Since you have the JDK in C:\Program Files\Java\jdk1.5.0_08, you have to add C:\Program Files\Java\jdk1.5.0_08\bin to the PATH.
[ June 10, 2007: Message edited by: Jesper Young ]

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

Joined: Apr 07, 2007
Posts: 57
Hi Alex Pol


you have to setclass path="set to bin folder in java";
as wel as JAVA_HOME="to java folder"..
Alex Pol
Ranch Hand

Joined: Sep 29, 2006
Posts: 33
"you have to add C:\Program Files\Java\jdk1.5.0_08\bin to the PATH."

To which "PATH"? JAVA_HOME?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14111
    
  16

No, to the environment variable named 'PATH'. See step 4 of the JDK installation instructions; the link is in my answer above.
[ June 11, 2007: Message edited by: Jesper Young ]
nitin goswami
Greenhorn

Joined: Mar 01, 2005
Posts: 25
Just to add:

Various Environment Variables:
------------------------------
PATH: Path of the Folder/Directory which contains the executable(.exe) files should present in PATH. Generally every application keeps there .exe files in BIN directory.(e.x. JDK, Tomcat, JBoss ...etc) thus for example: for J2SDK installed in the following location then C:\j2sdk1.4.1_03\bin should be there in PATH variable.

CLASSPATH: This environment variable keeps track of all the class files which we want to make available for "Compiler Search". If you want your class to be found by javac tool, mention the location of the file(s) in CLASSPATH variable or put that file in the directory from where you are running javac command.

JAVA_HOME: Is the way to tell a Tool (ex. Tomcat ) that my JDK is installed in the specified location. Actually These tools use JAVA_HOME environment variable as the part of the implementation of various functionality knowing the fact that user can install the JDK at any location so providing a user flexibility and to generalize their functionality implementation JAVA_HOME comes into picture.

Any suggestions or comments will be appreciated.

Thanks
-Nitin
Mahi Rahman
Greenhorn

Joined: Feb 16, 2007
Posts: 21
C:\Program Files\Java\jdk1.5.0_08\bin

and it should work now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Command "java" works, but "javac" does not