File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Ant unable to find javac compiler (in Eclipse) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Ant unable to find javac compiler (in Eclipse)

Sascha Balkau
Greenhorn

Joined: Jan 25, 2006
Posts: 8
Hi,
Since I've re-installed my Windows system, I got a problem that when I try to compile with Ant in Eclipse, it gives me an error that the Java Compiler cannot be found ...

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

However, I've set an env var named JAVA_HOME to my JDK path (D:\Java\jdk1.5.0_06\) and I've also added the bin folder to the path etc. I can use the compiler on the command prompt but Ant keeps telling me this error. What would I have to do to satisfy Ant?
[ April 23, 2006: Message edited by: Sascha Balkau ]
Sascha Balkau
Greenhorn

Joined: Jan 25, 2006
Posts: 8
Ah nevermind, I have figured it out by adding the tools.jar from JDK/lib to the classpath for Ant in Eclipse.

However now I got a different problem ...

When I compile and try to run a class that is not in the default package, I get a bunch of errors ...

E:\Works\Eclipse\Java Test\bin\testpack>java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong name: testpack/Test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


I'm puzzled with this! What could be wrong now?
Thanks for any hints!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

See my answer in your other thread.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Please don't cross-post.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
Don't get me started about those stupid light bulbs.
 
subject: Ant unable to find javac compiler (in Eclipse)
 
Similar Threads
Help with Ant build
Problems Running ANT target.
Unable to find a javac compiler
Ant javac
com.sun.tools.javac.Main is not on the classpath With JBOSS