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 / August 2006

Tip: Looking for answers? Try searching our database.

is there a web page with a

Thread view: 
tiewknvc9 - 14 Aug 2006 16:06 GMT
Is there a web page that details the java coding differences between
running a java application in a directory structure, and running an
application as a jar file?

Basically I have created a java application.  In my debugger, of
course, it is in a directory structure, so I reference things like
images by opening the image file in myapp\images\myimage.jpg

However this fails when I jar the application.  Of course it fails!
It's in a jar file!

But I was looking for a reference page on how to alter my code for all
occurrences similar to this.  Surely there must be some web page that
details what I would need to do to make my application jar --- safe?

Thanks!
Ingo R. Homann - 14 Aug 2006 16:13 GMT
Hi,

The solution is Class/Classloader.getResource()/getResourceAsStream().

It should be not too difficult to find all occurances of file-access in
your project (with your IDE, with 'grep' or even with an editor) and a
bit more laborous to change the code in the apropriate way.

Hth,
Ingo
tiewknvc9 - 14 Aug 2006 16:19 GMT
Ah,

This I knew.  My question is, is there a <b> website </b> that details
ALL of the code changes that one would need to make in order to make
the application jarred without errors?

Basically I dont want to go through each and every problem that arises
from jarring a file, I would rather work off of a reference, instead of
having to research each problem individually.

Thanks for the response though :)

> Hi,
>
[quoted text clipped - 6 lines]
> Hth,
> Ingo
gerry.hallahan@gmail.com - 14 Aug 2006 21:38 GMT
Check out JAR in  Java Glossary as mindprod.com

http://www.mindprod.com/jgloss/jar.html
Tom Cole - 15 Aug 2006 13:14 GMT
Any resources that are not classes (i.e. text files, images, etc.) will
need to use the Classloader to get them. That's it. It's not that
complicated. No other changes needed. Classes will automatically find
themselves as the Classloader is already looking in the jar (since the
first class with the main method was loaded from it...)

> Hi,
>
[quoted text clipped - 6 lines]
> Hth,
> Ingo
Simon Brooke - 14 Aug 2006 21:41 GMT
> Is there a web page that details the java coding differences between
> running a java application in a directory structure, and running an
[quoted text clipped - 6 lines]
> However this fails when I jar the application.  Of course it fails!
> It's in a jar file!

Backslashes.

Don't hard code your path separators - use java.io.File.separatorChar

Signature

simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/



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.