Chaim Geretz
Chaim Geretz

Reputation: 856

What root directory is used by the JVM for resolving relative URLs?

I need to maintain/install the following java code:

javax.xml.transform.Transformer t =
    tf.newTransformer(new javax.xml.transform.stream.StreamSource("foo.xsl")) ;

Where does the foo.xsl file need to reside in order to be found ?

Upvotes: 0

Views: 727

Answers (3)

unbeli
unbeli

Reputation: 30248

That would be relative to the current directory of the JVM process. Kind of "where you were standing" when you've started the JVM.

Upvotes: 1

Martijn Courteaux
Martijn Courteaux

Reputation: 68887

In OS X and Windows, this is normally the folder containing the JAR file.
In Linux, it might be the user home directory? If it isn't the home dir, it will be the same as in OS X and Windows. So be careful with it in Linux.

Upvotes: -1

ziesemer
ziesemer

Reputation: 28697

This will use the current working directory of the application.

Your best bet is to load it as a resource out of the classpath instead, which means that you can place the .xsl file in your application JAR, etc.

I have some existing documentation around this on my own blog. See "6. XSLT Inheritance" at http://blogger.ziesemer.com/2009/01/xml-and-xslt-tips-and-tricks-for-java.html.

Upvotes: 2

Related Questions