• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ant build script complains about Java home settings  RSS feed

 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Ant 1.9 for Java build. I have 2 different version of Java (1.6 and 1.7) for different environments. When I run the Ant build, I get the following error

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\jre6".

When I searched online, I see that setting the JAVA_HOME solves this issue. However since I have different Java version, I cannot use any specific Java home settings. I am not sure what the resolution is. If anyone can suggest a solution then it will be helpful.


Regards
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nitinram agarwal wrote:
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\jre6".

When I searched online, I see that setting the JAVA_HOME solves this issue. However since I have different Java version, I cannot use any specific Java home settings. I am not sure what the resolution is. If anyone can suggest a solution then it will be helpful.


A JRE (aka a Java Runtime Environment) is for running Java programs only. It does not contain a java compiler. If you want a Java compiler, you will need to install a JDK. From the name of the directory, I will guess that you only installed a JRE.

Henry
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to make a specific JDK available to Ant. In past, I have used Ant 1.5 and always used to specific the JRE in the run dialog box. Not sure if there is something changed in Ant 1.9.

Here is one of the link I am referring to and as I said setting Java_home resolves the issue but I don't want to do that

http://stackoverflow.com/questions/1558780/why-does-ant-tell-me-that-java-home-is-wrong-when-it-is-not


I also tried something else..



and this resolves the issue (no specific JDK set up or setting up of environment variable). I want to make sure that whatever the solution I am using is right.
 
nitinram agarwal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resolved the issue by pointing the JDK while running ant build. Marking the issue as resolved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!