I have a Sonic game I am in the process of building and must say it is coming along quite nicely. I've got everything up and running, except for this one little issue. Now, my friends who are helping all have a Java IDE of some form or another and are able to simply open the project in thier IDE and handle things form there. However, now that the game is nearing completion I must start thinking about distribution, therefore I thought to myself "Well, the easiest way is to pack everything in an executable .jar file and BAM! Double click and enjoy the game". However, whenever I generate the exec .jar by doing a clean and build in Netbeans, it generates the .jar, I go to the dist folder and double click to run, but none of my files appear, just the blank JFrame without any graphics or sounds.
Now here is the interesting thing...
I went back to a previous version of the project where my filepaths I passed in to my "Artist" class (class I wrote methods in for handling images and sounds) are all pointing to specific places on my hard drive. However, yesterday I went and added all my files to a "Resources" folder on the same level in the project directory as the dist, build, src, etc... folders. When I call my filepath now instead of something like "C:\\Users\\Ike\\Sonic Game\\Pictures\\Sonic_Running.png" I am able to simply call something like "Media\\Images\\Sonic_Running.png" and all is fine and dandy when running it from the IDE. BUT... then I try and build this executable .jar file and all my hard work vanishes into a blank JFrame when I run it from the executable .jar despite still running fine within the IDE.
If you could write out some step by step directions for how exactly to get the project to run from the executable .jar file I would really appreciate it, as well as a bunch of people on the internet looking foward to this game. Thanks
> If you could write out some step by step directions for how exactly to get the project to run from the executable .jar file
step-by-step to get help:
1) add an image to a JLabel
2) add the label to a JFrame
3) compile/run in IDE - if image appears OK, goto (4)
4) make a .jar file out of it
5) open .jar file - if no image, goto (6)
6) post the code here, so we can see what you're doing
> Here is a video I made detailing the problem...
useless, unless it shows the code
Joined: Jan 01, 2013
Well, after spending a good 3 days straight working on this I managed to stumble across this page...
http://www.vbforums.com/showthread.php?595275-RESOLVED-Images-embedded-into-JAR-file Not sure how my countless prior Google searches did not come up with this but nevertheless this was pretty much my exact problem (except for the spelling issues). All I gotta do is rework my ImageHandler, AudioPlayer, and FileHandler classes to create a URL and have whatever class is using it use that instead. It is a shame though this beautiful, elegant, lovely code I constructed and have been using for this project for a year now needs modifications but oh well, they are small and easy to do, just a little tedious going through each adn every place I use these classes on my pretty-much-ready-to-distribute game. Oh well..
Anyways, I seem to have resolved my own problem. Sorry to be any inconvience.