Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Noob questions: Saxon 9 and XQuery 1

Status
Not open for further replies.

NuJoizey

MIS
Aug 16, 2006
450
0
0
US
I'm so green at XML that it isn't funny.

Anyway, I'm trying to work through an XQuery book example. I've downloaded and installed Saxon9. I used it successfully to do XPath transformations so far. I am running the Java version on W2k3 Server from DOS command line.

The problem is that the example as well as the saxon documentation says that I should be able to access the XQuery functionality by typing:

java net.sf.saxon.Query -?

at the command line - but the problem is that I can't, I get a java.lang.NoClassDefFoundError sf/saxon/Query.

So now what do I do? If I browse the saxon9.jar file I can see that the path and the Query.class file exists. I have tried calling the command from directly within the saxon directory, but no dice.

How now brown cow?
 
Specify the classpath to the saxon9.jar in whatever, say c:\progra~1\saxon9\saxonb9j or whatever, like this.
[tt] java -cp [green]c:\progra~1\Saxon9\Saxonb9j\[/green]saxon9.jar net.sf.saxon.Query -?[/tt]
 
OK just tried that - still says "could not find the main class: Files\Saxon\saxon9.jar" the same error as before.

saxon9.jar is located in C:\Program Files\Saxon

the exact command I am typing is java -cp C:\Program Files\Saxon\saxon9.jar net.sf.saxon.Query -?

I don't get why it can't find the main class - Is this an issue with my CLASSPATH?
 
Have you seen I use short name on component with space?
 
ah yes. bingo. thank you very much - it works with the short name.

As long as we're on the topic, I tried setting my classpath so that I should be able to call saxon commands from other places in the file system other than in the directory where saxon9 resides (that's the whole point of classpath, right?), but for some reason it won't recognize any commands outside of the Saxon directory.

My environment variable is set to:

C:\Program Files\Saxon\

perhaps I should try setting it to

C:\Progra~1\Saxon\

 
If you mean to put it in the classpath env variable, absolutely.
 
i guess this was really more of a java compiler question than it was XML
 
i tried setting the classpath to C:\Progra~1\Saxon\ (as suggested above by tsuji so i wouldn't have to enter the full directory name every time I make a call to saxon, but it still doesn't work.

In other words, every time I want to run a transformation I need to type:

java -cp c:\progra~1\Saxon9\Saxonb9j\saxon9.jar net.sf.saxon.Query -?

but if my CLASSPATH is set up right, I should only have to type

java net.sf.saxon.Query -?

What am i doing wrong?


 
[tt]java [red]-cp[/red] net.sf.saxon.Query -?[/tt]
 
correction
I miss the point. The above line is a mistake. It should work with
[tt] java net.sf.saxon.Query -?[/tt]
There are usually a couple of things to look rightaway: competition of the .jar class if an outdated path appears before it, or the classpath becoming too long... The latter is an issue.
 
it doesn't work with

java net.sf.saxon.Query -?

As far as I can tell, the paths are not outdated.

Perhaps it just doesn't like the fact that it resides in C:\Program Files\ with the long file name and space. Maybe if I had installed it to C:\Saxon it would work.

It seems like there's not much else it could be. I guess I will try that when I have finished working through my examples. Now that its at least working, I'll deal with the extra typing for the moment.

Thanks for trying to help me, though.
 
>Perhaps it just doesn't like the fact that it resides in C:\Program Files\ with the long file name and space.
I don't understand. Didn't we settle on that issue already? If everything gets round about all the time, it does not get anywhere.
 
the only issue settled was that this command works appropriately to call Saxon:

java -cp c:\progra~1\Saxon9\Saxonb9j\saxon9.jar net.sf.saxon.Query -?

while this one is not

java -cp c:\Program Files\Saxon9\Saxonb9j\saxon9.jar net.sf.saxon.Query -?

I still dont have an answer as to why I even have to specify the -cp argument at all when my CLASSPATH environment variables are set up. [ponder]
 
So now you know by yourself. That is fine for me.
 
Are the two posts of 14 May 09 10:31 and 14 May 09 10:40 dealt with the issue?
 
here is the apparent answer to my question:

I needed to include the jar in the name, not just the directory, because it is packaged in a jar.

Setting CLASSPATH="C:\Progra~1\Saxon\saxon.jar

seems to make it function as it should.

Now I can call Saxon by the command

java net.sf.saxon.Query -?

from anywhere in my OS file system.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top