Summary: | Ant build fails inside Eclipse with JDK 1.7u2 | ||
---|---|---|---|
Product: | [JogAmp] Jogl | Reporter: | Wade Walker <wwalker3> |
Component: | core | Assignee: | Wade Walker <wwalker3> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | sgothel |
Priority: | --- | ||
Version: | 2 | ||
Hardware: | All | ||
OS: | all | ||
Type: | --- | SCM Refs: | |
Workaround: | --- |
Description
Wade Walker
2011-12-22 15:50:45 CET
Can duplicate this on the command line:
> java -classpath "C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar" com.sun.tools.javah.Main
-d "C:\Users\wwalker\Documents\jogl2\gluegen\build\gensrc\native"
-classpath "C:\Users\wwalker\Documents\jogl\gluegen\build\classes"
jogamp.common.os.MachineDescriptionRuntime
Exception in thread "main" java.lang.NullPointerException
at com.sun.tools.javah.JavahTask.run(JavahTask.java:509)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:335)
at com.sun.tools.javah.Main.main(Main.java:46)
Not sure why it fails like this, but works when run inside Ant on the command line. There may be something else on the classpath that's not being put there in the Eclipse run.
Very strange. When I invoke javah like this, it fails: jogl2\gluegen> java.exe -classpath "C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar" com.sun.tools.javah.Main -d build\gensrc\native -classpath build\classes jogamp.common.os.MachineDescriptionRuntime Doing it like this also fails (this is how ant -debug shows it being done inside Eclipse): jogl2\gluegen> "C:\Program Files\Java\jre7\bin\java.exe" -classpath "C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar" com.sun.tools.javah.Main -d build\gensrc\native -classpath build\classes jogamp.common.os.MachineDescriptionRuntime But like this, it succeeds: jogl2\gluegen> "C:\Program Files\Java\jdk1.7.0_02\bin\java.exe" -classpath "C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar" com.sun.tools.javah.Main -d build\gensrc\native -classpath build\classes jogamp.common.os.MachineDescriptionRuntime Continuing to investigate. The two java executables appear identical, so there must be some path dependency perhaps. Found the problem. In Java 7, Ant needs to be launched with a Java executable from a JDK, not a JRE, or else the javah task won't work correctly, even if you set the Ant java.home property to the JDK directory. Eclipse launches Ant with the workbench VM, which is not set from JAVA_HOME, so it ends up chosing C:\Program Files\Java\jre7\bin\javaw.exe instead of C:\Program Files\Java\jdk1.7.0_02\jre\bin\javaw.exe, which makes it unable to use tools.jar correctly (since it's only present in the JDK). I changed the wiki at http://jogamp.org/wiki/index.php/Building_JOGL_in_Eclipse to give instructions on how to tell Eclipse to launch Ant with your JAVA_HOME JDK instead of the other JRE. |