I downloaded Xalan-Java Version 2.7.1
, unpack it, and then set the PATH
for java and CLASSPATH
for xalan:
set path=%PATH%;c:\Program Files\Java\jre6\bin
set classpath=%CLASSPATH%;c:\Xalan\
(I also tried setting the classpath only for xalan.jar, xercesImpl.jar, xml-apis.jar)
When testing a simple Hello World example (or any other example):
java org.apache.xalan.xslt.Process -in hello.xml -xsl hello.xsl -out hello.html
I always get this:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xalan/xslt
/Process
Caused by: java.lang.ClassNotFoundException: org.apache.xalan.xslt.Process
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.apache.xalan.xslt.Process. Program will exit
What is the problem ? Someone has an idee ?
Thanks.
Serializer should not be needed in all cases. For example, if you XSLT was making use of pipeDocument then it would be needed.
This error points to not finding "org.apache.xalan.xslt.Process" of xalan.jar. Recheck your classpath. Exclude hello.xml and hello.xsl to avoid them muddying the water. If your classpath is correct, this alone
will provide output (Xalan-J command line options).
Ok, this is what I did to make it work, finally:
Copy the
xalan.jar
to thec:\Program Files (x86)\Java\jre6\lib\
Running the file like this from command line:
Without
serializer.jar
it doesn't work !