Reputation: 708
I am in the folder :
/cygdrive/d/ragsxq
where I have kept some simple X-Query stmts to be executed via Saxon X-Query engine...(Saxon 9.4 HE )
The following statement :
$ java -classpath /cygdrive/d/saxon/saxon9he.jar net.sf.saxon.Query -q:ragsXQuery.xq
gives :
java.lang.NoClassDefFoundError: net/sf/saxon/Query Caused by:
java.lang.ClassNotFoundException: net.sf.saxon.Query 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:
net.sf.saxon.Query. Program will exit. Exception in thread "main"
But the below statement works fine:
$ java -classpath ../saxon/saxon9he.jar net.sf.saxon.Query -q:ragsXQuery.xq
?!?!
Something to do with the Class-loader..?? Permmissions..?? Cygwin ? Hmmmmm...
Thanks a lot for pointing out this Cygwin behavior!
But the strange thing is, i run into this java.lang.NoClassDefFoundError
(exactly the same as above) when I try to Run an Xquery via my Eclipse (Indigo) on Mac OS Lion too...via the XQDT plugin, where I have to configure the XQuery engine by providing the full-path of the saxon9he.jar & the main-class viz., net.sf.saxon.Query
Note that a similar set-up on Windows-XP works fine.
This time, I guess it could be some Classpath issue or the way Mac OS's Java treats things differently ?
Upvotes: 2
Views: 789
Reputation: 62583
I think I have faced this before. It is probably a Cygwin nuance. Just try
$ java -classpath `cygpath -m /cygdrive/d/saxon/saxon9he.jar` net.sf.saxon.Query -q:ragsXQuery.xq
Here is a possible explanation as to why:
http://cygwin.com/ml/cygwin/2008-01/msg00083.html
Below is the output from my Cygwin for an executable JAR file. I use Windows Vista 32 bit (I know, it sucks).
adarshr$ java -jar /cygdrive/d/adarshr/data/cf.jar
Error: Unable to access jarfile /cygdrive/d/adarshr/data/cf.jar
adarshr$
adarshr$ java -jar `cygpath -m /cygdrive/d/adarshr/data/cf.jar`
Usage: java -jar cf.jar SEARCH [DIRECTORY] [OPTIONS]...
Try -h or --help for more information
As you can see, the second command worked and printed a help (as expected).
Upvotes: 4