File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Including external files in exported .jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Including external files in exported .jar?" Watch "Including external files in exported .jar?" New topic

Including external files in exported .jar?

Michael Keisu
Ranch Hand

Joined: Oct 08, 2009
Posts: 30
I have had some problems when I have tried to export my game projects as a runnable .jar file in Eclipse, images and and none source files don't get included in the jar, so I had to place them outside (on the same level as the jar) to get it to work properly.
How do I fix this problem?

Stephan van Hulst

Joined: Sep 20, 2010
Posts: 3598

Well, you can create the jar file yourself using the jar tool that comes with the JDK. Then when you load the images, use Class.getResource() or Class.getResourceAsStream() to get access to them.
Michael Keisu
Ranch Hand

Joined: Oct 08, 2009
Posts: 30
Thanks, I will look into them.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
I bookmarked this tutorial on "getResource" (about half way down the page) for myself. It's been helpful, as it includes several different scenarios.
I agree. Here's the link:
subject: Including external files in exported .jar?
Similar Threads
Question regarding a JAR
need help with Xerces
Finding JAR files
quickie... how to unzip a jar file via a java command line from the MSDos window?