A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Resources in JAR
Joined: Oct 20, 2001
Oct 27, 2004 00:53:00
can we place images and other IO Files (Resources other than .class files) in
that are used in application ? if yes than how?
Joined: Feb 02, 2002
Oct 27, 2004 01:00:00
In general, Yes.
Just as you would place class files in a jar; by using the jar tool. jar command doesnt differentiate between class files or any other files, all files in the target directory are included in the generated jar.
The future is here. It's just not evenly distributed yet. - William Gibson
Joined: Jun 23, 2004
Oct 27, 2004 10:54:00
A classloader loads the jars so, the files in a jar are accessed from the classloader. Use the method classloader.getResourceAsStream(
), or URL classloader.getResource(String).
To make sure you are using the same classloader as the one that loaded the jar, you should get the classloader from a object who's class is in the jar.
Classloader classloader = someObject.getClass().getClassloader();
If you want to access the jar with jar apis, you can get a url then use jar api's.
I agree. Here's the link:
subject: Resources in JAR
java.util.MissingResourceException: Can't find bundle for base name in JSF Spring Maven project
Class path question
So I Got This Game, See...
EJB JAR resources classloader issues
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015