When running an ivy resolve via IvyDE in Eclipse, which contains a packager.xml that executes a javac ant task, I get the following:
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 Fil开发者_如何学运维es\Java\jdk1.6.0_22\jre" at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:108)
In eclipse.ini I have
-vm
C:\Program Files\Java\jdk1.6.0_22\bin\javaw.exe
and in Help - About Eclipse - Installation Details - Configuration I see
java.home=C:\Program Files\Java\jdk1.6.0_22\jre
How can I make java.home point to C:\Program Files\Java\jdk1.6.0_22
instead?
Eclipse uses its own javac implementation internally. Therefore for most of the purpose you just need a compatible JRE. But javac task in ANT considers the JAVA_HOME or check for the local path
variable. On windows machine as temporary fix you can do:
Open a command prompt
then type
SET path=C:\Program Files\Java\jdk1.6.0_22\;%path%
hit enter
then type
<eclipsehome>\eclipse.exe
Now any process spawned from your eclipse will have your JDK version in the path variable.
for a permanent solution..
1. go to advance system setting
2. select advanced
tab
3. select environment variables
4. modify the system path
variable and JAVA_HOME (if required)
You can do the similar thing for *nix system (just check how to set environment setting on them)
Hope this will work.
UPDATE
The PROJECT classpath isn't the same as the ANT classpath. To set up an Ant classpath, navigate to window->preferences->ant->runtime
here check whether the Global Entries
points to C:\Program Files\Java\jdk1.6.0_22\lib\tools.jar
if not then add it. Normally it works in most of the cases where ant cries for javac task. if it fails then please check whether some other script is not resetting your JAVA_HOME variable and ANT global entries
setting.
If IvyDE is not using the ANT bundled with eclipse as plugin (and referring to some standard installation) or if you have defined a environment variable like ANT_HOME then copy
tools.jar
file from C:\Program Files\Java\jdk1.6.0_22\lib\
to ANT_HOME\lib
.
Also check this previous SO post ( Ant can't find Javac. No matter what I do it always claims JAVA_HOME is "C:\Program Files\Java\jre6" )
UPDATE 2 ok.. Check this page... http://ant.apache.org/ivy/ivyde/history/latest-milestone/preferences.html
Order of the classpath entries: By default, the classpath container entries are ordered by order of declaration in the ivy.xml. When there are many entries, it can be useful to have them ordered lexically for enhanced readability.
Is tools.jar
present in ivy.xml
? please check once.
精彩评论