Java Reference
In-Depth Information
and Xerces, the version of these libraries must override the default Java versions
through the Java-endorsed mechanism.
1, 2
Move all
XML
libraries to a subdirectory of
HT
mlUnit-2.7/lib called
endorsed
. For
example, the lib directory should contain the following files:
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-httpclient-3.1.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
cssparser-0.9.5.jar
htmlunit-2.7.jar
htmlunit-core-js-2.7.jar
nekohtml-1.9.14.jar
sac-1.3.jar
serializer-2.7.1.jar
The directory lib/endorsed should contain these files:
xalan-2.7.1.jar
xercesImpl-2.9.1.jar
xml-apis-1.3.04.jar
Your classpath must list all
JAR
files in lib. In addition, you must add the following to
your Java
VM
invocation:
-Djava.endorsed.dirs=C:\Java\htmlunit-2.7\lib\endorsed
If you're lucky enough to develop on Java 6, your command line classpath doesn't
need to list each HtmlUnit
JAR
file; instead, it can contain
C:\Java\htmlunit-2.7\lib\*
Starting with Java 6, at last you can use
*
to include all
JAR
files in a directory.
E.1.2
Eclipse configuration
In Eclipse, you must set up a
JRE
as shown in figure E.1.
The two key items in this
JRE
configuration are as follows:
Default
VM
Arguments sets the endorsed path to our HtmlUnit lib/endorsed
directory.
■
JRE
System Libraries lists the HtmlUnit lib/endorsed
JAR
files first.
■
Eclipse will automatically set up all other entries in the
JRE
System Libraries list.
1
For Java 5, see
http://java.sun.com/j2se/1.5.0/docs/guide/standards/index.html.
2
For Java 6, see
http://java.sun.com/javase/6/docs/technotes/guides/standards/.