File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Error :Unable to find a javac compiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error :Unable to find a javac compiler" Watch "Error :Unable to find a javac compiler" New topic
Author

Error :Unable to find a javac compiler

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
Hi,
I get the following error when i try executing my web application.

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK


The follwing is installed:
j2sdk1.4.2_06,Tomcat 5.0.28
OS-winxp sp2

Advanced->Environmental Variables->User Variables->
JAVA_HOME=C:\j2sdk1.4.2_06;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
Classpath=C:\j2sdk1.4.2_06\lib\tools.jar

Advanced->Environmental Variables->System Variables->
Path=C:\j2sdk1.4.2_06\bin

Request your help.


Thanks,
Pratap koritala
Ranch Hand

Joined: Sep 27, 2006
Posts: 252
In JAVA_HOME=C:\j2sdk1.4.2_06;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar

Why you included C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar

use JAVA_HOME=C:\j2sdk1.4.2_06

Include C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar in classpath
[ August 29, 2008: Message edited by: Pratap koritala ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40059
    
  28
And why are you using packages beginning com.sun? You will have to check, but there is a risk that packages beginning com are experimental and might be removed in later releases of Java.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14435
    
  23

Originally posted by Phillipe Rodrigues:
Advanced->Environmental Variables->User Variables->
JAVA_HOME=C:\j2sdk1.4.2_06;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
Classpath=C:\j2sdk1.4.2_06\lib\tools.jar

Advanced->Environmental Variables->System Variables->
Path=C:\j2sdk1.4.2_06\bin

Your JAVA_HOME is wrong; it should be set only to C:\j2sdk1.4.2_06. Remove the reference to the Tomcat servlet-api.jar from your JAVA_HOME.

Your CLASSPATH is also strange. You do not need to add tools.jar to the CLASSPATH. It's best to leave the CLASSPATH variable not set (delete it).

Your PATH setting is correct.
Originally posted by Campbell Ritchie:
And why are you using packages beginning com.sun? You will have to check, but there is a risk that packages beginning com are experimental and might be removed in later releases of Java.

Campell, Philippe most likely is not using the Sun packages himself. The Java compiler itself is written in Java and the package that the error refers to is the package where the compiler is implemented.
[ August 29, 2008: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40059
    
  28
Originally posted by Jesper Young:

Campell, Philippe most likely is not using the Sun packages himself. The Java compiler itself is written in Java and the package that the error refers to is the package where the compiler is implemented.
That's all right then.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error :Unable to find a javac compiler