aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Including external files in exported .jar?" Watch "Including external files in exported .jar?" New topic
Author

Including external files in exported .jar?

Michael Keisu
Ranch Hand

Joined: Oct 08, 2009
Posts: 30
Hi.
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?

Mike
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

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
    
    1
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: http://aspose.com/file-tools
 
subject: Including external files in exported .jar?