loading files from a jar

F

frank

Had something working just fine when the files where on the local file
system but now that I have them in a jar it's not working. I believe
the paths are correct just seems to be going to the local file system
and not the jar file.


String styleSheet = xss/style.xsl

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(
styleSheet));

Thanks,

Frank
 
R

Roedy Green

Had something working just fine when the files where on the local file
system but now that I have them in a jar it's not working. I believe
the paths are correct just seems to be going to the local file system
and not the jar file.

It is behaving as advertised.


you are doing effectively
new StreamSource( "xss/style.xsl" );

StreamSource is expecting an URL, e.g. the result of a getResource.

You gave it a relative URL which I presume it is interpreting as:

file:xxx/style.xsl

a file in the CWD of the local file system, not a resource.

Try feeding the rnesult of a getResourceAsStream(" xss/style.xsl" );
instead where that file is stored under the current package name in
the jar.

http://mindprod.com/jgloss/image.html

and
http://mindprod.com/jgloss/resource.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top