ANT built errors in Eclipse

From OpenJUMP Wiki
Jump to navigation Jump to search

http://www.eclipseplugincentral.com/PNphpBB2+file-viewtopic-t-2046.html


[javac] BUILD FAILED: [build file location here]
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

Of course, JAVA_HOME is pointing to the right location, in both the OS environment and within Eclipse (This variable can be set within Eclipse through Window > Preferences > Java > Classpath Variables).

So how to fix the Ant build problem?

I found various solutions searching, for example running Eclipse with "eclipse -vm [JDKPATH]\bin" but that didn't quite satisfy me (I wanted something that could be configured within the environment). Other solutions to the problem where even more esoteric.

The best solution I've found (after a little bit of digging through Eclipse's options) is to edit Ant's runtime properties. Go to Window > Preferences > Ant > Runtime. Choose the Classpath tab. Select the Global Properties node in the tree and click Add External JARs. Select tools.jar from your JDK directory (e.g., j2sdk1.4.2_03\lib\tools.jar). Click Apply and OK, and you should be on your way. Not too hard when you know what to do. Now if this could only be done automatically by Eclipse on install...


java.lang.UnsupportedClassVersionError:
com/sun/tools/javac/Main (Unsupported major.minor version 49.0)

I resolved the issue. Here's what I did in case anyone else runs into the same problem. I right clicked on the build.xml file in the Package Explorer, chose the "Run" menu from the popup, and the "External Tools" option in the "Run" sub-menu. In the External Tools window, I clicked the "JRE" tab, and selected the "Run in the same JRE as the workspace".