Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

getResource() and jar files?

Thread view: 
Knute Johnson - 09 Mar 2007 17:04 GMT
If you have an application in a jar file and use getResource() to load
something, how do you get it to load something that isn't in the jar file?

Thanks,

Signature

Knute Johnson
email s/nospam/knute/

Lothar Kimmeringer - 09 Mar 2007 17:26 GMT
> If you have an application in a jar file and use getResource() to load
> something, how do you get it to load something that isn't in the jar file?

getResource is looking into the places residing in the classpath.
If something is in the classpath it will be found. If it doesn't
it will not.

Regards, Lothar
Signature

Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
              PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                questions!

Knute Johnson - 09 Mar 2007 18:25 GMT
>> If you have an application in a jar file and use getResource() to load
>> something, how do you get it to load something that isn't in the jar file?
[quoted text clipped - 4 lines]
>
> Regards, Lothar

So say I have an app in a jar, test.jar.  I set the classpath in
test.man to '.'.  It still won't find my resource in the current
directory.  Does the classpath have to be another jar file?

Thanks,

Signature

Knute Johnson
email s/nospam/knute/

Brandon McCombs - 10 Mar 2007 00:32 GMT
>>> If you have an application in a jar file and use getResource() to
>>> load something, how do you get it to load something that isn't in the
[quoted text clipped - 11 lines]
>
> Thanks,

Your MANIFEST.MF file in the JAR file should specify the classpath. What
is test.man in your example??  Build your JAR file with a MANIFEST.MF
that looks something like this:

Manifest-Version: 1.0
Main-Class: org/myorg/myapp/gui/MyApp
Class-Path: lib/myapp1.jar lib/myapp2.jar

Do not include an extra line after Class-Path. If you put your path as
another path entry it should work. Resources for a JAR file should be
inside the actual JAR file so everything is packaged into a single bundle.
Knute Johnson - 10 Mar 2007 06:29 GMT
> Resources for a JAR file should be
> inside the actual JAR file so everything is packaged into a single bundle.

That's my question, can I have resources that are not in the jar?  If
so, how do I reference them in the manifest file?

Signature

Knute Johnson
email s/nospam/knute/

Chris Uppal - 10 Mar 2007 16:07 GMT
> That's my question, can I have resources that are not in the jar?  If
> so, how do I reference them in the manifest file?

I'n curious.  I don't know the answer to your questioni for sure, but why do
you suspect that it /should/ be possible ?  Resources are loaded by
ClassLoaders, and ClassLoaders have nothing (in general) to do with the "local
file system".

   -- chris
Knute Johnson - 10 Mar 2007 17:14 GMT
>> That's my question, can I have resources that are not in the jar?  If
>> so, how do I reference them in the manifest file?
[quoted text clipped - 5 lines]
>
>     -- chris

Because if the class isn't in a jar you can load resources from
anywhere.  I just haven't been able to find a reference anywhere that
says you can't load them from sources other than jars if your app is in
a jar.  I think you can still load resources from the net if your app is
in a jar.

Signature

Knute Johnson
email s/nospam/knute/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.