If you face this problem, probably you are using Ant tasks that include the javac task for compiling Java source. This simply means that Ant could not find a Java compiler.
BUILD FAILED D:\research\ant\firstbuild\build.xml:9: 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. It is currently set to "C:\Program Files\Java\jre7" Total time: 0 seconds
For Eclipse user you can add items to Ant’s class-path from the Ant > Runtime preference page. If you launch Eclipse by using a full JDK instead of a JRE, tools.jar should appear on the Ant class-path automatically.
Ant also allowing you to plug in your own Java compiler, such as the Java compiler that is built into Eclipse. So alternatively, you can simply add the following line to your build file to specify the compiler:
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter">
</property>
If you executed the command from command line, make sure JAVA_HOME variable is set to JDK, instead of JRE in classpath variable. You can use following command to set JAVA_HOME varriable.
For Windows user:
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55
For Linux User:
export JAVA_HOME=/opt/java/jdk1.7.0_55
Apart from this you can explicitly mention ant to execute particular executable using following excerpt of code.
<?xml version="1.0"?>
<project name="firstbuild" default="compile">
<target name="compile">
<javac srcdir="."
destdir="."
fork="yes"
executable="C:\Program Files\Java\jdk1.7.0_55\bin\javac"
compiler="javac1.7"
/>
<echo>compilation complete!</echo>
</target>
</project>
I hope this should solve the problem. Please drop by if you have any query and feel free to make any suggestion.
Useful post with good explanation and thanks for taking time to share his post.
ReplyDeleteDigital Marketing Training in Chennai | SEO Training in Chennai
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteJava Training in Chennai Java Training in Chennai | Core Java Training in Chennai Java Training in Chennai
Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai
Excellent post!!!
ReplyDeleteqtp training in chennai
Useful post .
ReplyDeleteios training in chennai
Useful post with good explanation and thanks for taking time to share his post.
ReplyDeletejava training in chennai
Excellent post!!!.
ReplyDeleteselenium training in chennai
Wonderful post ! I like your blog. Thanks for sharing.
ReplyDeletewordpress Training center in Chennai
Excellent post on Java.I got some useful tips from your webpage.Keep sharing more.
ReplyDeleteThanks,
Java Courses in Chennai | J2EE Training in Chennai | JAVA Training Chennai
This data is great and amazing. A debt of gratitude is in order for taking an ideal opportunity to talk about this, I feel upbeat about it and I adore adapting more about this theme. I utilize your manual for teach my understudies.
ReplyDeleteRegards,
Hibernate Training in Chennai | Hibernate course in Chennai | Spring and Hibernate Training in Chennai
Useful post.Mobile application testing is a procedure by which application programming produced for handheld cell phones is tested for its consistency, functionality and usability.
ReplyDeleteThanks,
Mobile Testing Training in Chennai | Mobile Testing Training | Mobile Apps Testing
Im no expert, but I believe you just made an excellent You certainly understand what youre speaking about, and I can truly get behind that.
ReplyDeleteBest JAVA Training institute in Chennai|Java Courses in Chennai