You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Klas Eriksson <kl...@micronic.se> on 2004/08/06 13:17:10 UTC

junit and fork:ed non-jre jvm

Hi
 
How to use junit+fork but still use jdk/bin/java and not jre/bin/java?
---
I have a unit test that internally use the java compiler from Sun:
com.sun.tools.javac.Main
it is defined in lib/tools.jar that normally is included in jdk/bin/java.
(I use junit fork=true as a workaround for:
java.lang.LinkageError: loader constraints violated when linking
org/w3c/dom/Document class
works fine.)
 
But fork changed jvm from jdk/bin/java to jre/bin/java
that doesn't include the class com.sun.tools.javac.Main.
 
So, I tried to force junit/fork to use jdk/bin/java with the 'jvm'
attribute:
<junit fork="true" jvm="${env.JAVA_HOME}/bin/java.exe">
I see that I now run the jvm I want, but it is tweaked by junit not to
include tools.jar.
I still get:
java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
 
If I remove the 'fork=true' attribute, the class is found and the test works
fine,
but then other tests that use xml get the LinkageError above.
 
Any clue why? How do I run the jdk/bin/java booted as *usual*?
 
/klas