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 / First Aid / November 2004

Tip: Looking for answers? Try searching our database.

.jpg images in a jar file.

Thread view: 
peter2929 - 26 Nov 2004 17:48 GMT
Hello all,

I,ve recently put all my application files into a jar file,
only to discover that the .jpg images are loaded into the
jar file but not recognised when executed.  All the other
files work fine.
Can anyone tell me what is wrong and a possible solution?

Many thx Peter.
Andrew Thompson - 26 Nov 2004 18:00 GMT
> I,ve recently put all my application files into a jar file,
> only to discover that the .jpg images are loaded into the
> jar file but not recognised when executed.  

What does that mean exactly, are exceptions thrown
when you try to load them?  If so, what exceptions?
<http://www.physci.org/codes/javafaq.jsp#exact>

>...All the other files work fine.

Are there any other files besides classes?

> Can anyone tell me what is wrong and a possible solution?

Probably that the .jpg's are not being found*.
<http://www.physci.org/codes/javafaq.jsp#path>

[ * Though it is quite hard to say without seeing your code. ]

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

peter2929 - 26 Nov 2004 23:13 GMT
> > I,ve recently put all my application files into a jar file,
> > only to discover that the .jpg images are loaded into the
[quoted text clipped - 14 lines]
>
> [ * Though it is quite hard to say without seeing your code. ]

Ok, let my clarify.

There is nothing wrong with the code, no errors or exceptions occur.
The app works perfectly well without the jar file on its own,
recognising all the external files (.jpg and .txt) and loading
them into the app as expected. (No problems here).

When I put them into my jar file, which is executable, they increase
the file size as expected, but when I double click my Jar file,
the app works as normal but with all the .jpg images missing!
Thats the problem. I tried putting them into a seperate folder,
but it made no difference.  If I put the jar file back into the
folder with all the images, then it works fine, because it is still
looking for those images and not the ones I put inside the jar file.
I hope all this makes sense,  I don't intend posting 0ver 300 lines of
code, I guess that would annoy a few people.

many thx Peter.
Andrew Thompson - 27 Nov 2004 03:09 GMT
> ..I don't intend posting 0ver 300 lines of
> code, I guess that would annoy a few people.

Trim it to a 30 line version that displays the same behaviour.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Tony Morris - 26 Nov 2004 23:52 GMT
> Hello all,
>
[quoted text clipped - 5 lines]
>
> Many thx Peter.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html#getResourceAs
Stream(java.lang.String
)

Signature

Tony Morris
http://xdweb.net/~dibblego/



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



©2009 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.