views:

208

answers:

1

How do I get the location of rt.jar in my Ant script with NetBeans without editing my project.properties? ${java.home} is returning the location of the jre folder and not the jdk folder.

I know that I could easily add a value to project.properties but I don't want to. I also know that I could easily just modify the path whenever I switch computers but I would prefer not to do that either.

Edit: Maybe ${java.home} is the best solution and I should just fix my computers environment variables correctly.

Edit2: I just realized that java.home is not the same as JAVA_HOME. More information: http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html

+1  A: 

Do you have JAVA_HOME set? If so does it point on a JDK? From the Ant documentation:

When you need JDK functionality (such as for the javac task or the rmic task), then tools.jar must be added. The scripts supplied with Ant, in the bin directory, will add the required JDK classes automatically, if the JAVA_HOME environment variable is set.

Pascal Thivent
JAVA_HOME isn't set in my environment details, but Ant has no problem compiling (using javac for instance). Ant works fine for everything, whats confusing is that my ${java.home} variable is set to "C:\Sun\SDK\jdk\jre" instead of "C:\Sun\SDK\jdk" which I'm assuming is the standard? I'm not new to Java as a language, but in terms of configuring it, etc I am. Is Java home supposed to point to the JDK or the JRE in the JDK? I re-installed Sun JDK with EE from Sun's website and it still didn't setup a JAVA_HOME environment, is that normal? Thanks
William
I see what I was doing wrong. JAVA_HOME and java.home are completely different. I just found this out thanks to http://javahowto.blogspot.com/2006/05/javahome-vs-javahome.html - your message got me to re-think the problem again so I'm setting this as the answer. Thanks!
William