Results 1 to 6 of 6
Thread: Creating Jar file with eclipse
- 04-11-2012, 03:46 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 84
- Rep Power
- 0
Creating Jar file with eclipse
I have a game and I import JPG files and read from XML file and also have couple class files. How do I convert all this into jar file in eclipse? I tried exporting to Jar but it won't run. Not sure what the manifest means either. Is there a easy to follow tutorial out there that I can do this pain free?
- 04-11-2012, 04:39 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 762
- Rep Power
- 14
Re: Creating Jar file with eclipse
You could start by learning the jar command. Here a tutorial that will guide you: Lesson: Packaging Programs in JAR Files (The Java™ Tutorials > Deployment)
Website: Learn Java by Examples
- 04-16-2012, 06:17 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 84
- Rep Power
- 0
Re: Creating Jar file with eclipse
ok. so i was able to create the jar file and can run it (running in older windows no problem, in windows 7 i had to create a shortcut). One of the things that is not working properly is the jpg images. the jar file runs if it's in the same folder as my jpg's. The jpg's are included in the jar file but won't run alone. Like, let's say, I move my jpg files to another location then the jar file will not run, even though the jpg files are included in the jar file. Why is that?
To load my images i use the code....
img = ImageIO.read(new File("rock.jpg"));
- 04-16-2012, 01:07 PM #4
Re: Creating Jar file with eclipse
Resources inside a jar file aren't files. You need to use another overload of ImageIO#read(...).
How to Use Icons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-27-2012, 06:23 AM #5
Member
- Join Date
- Sep 2010
- Posts
- 84
- Rep Power
- 0
Re: Creating Jar file with eclipse
got sidetracked with other work....but in last 4hrs i was able to change all the images from being read by bufferedreader to imageicon....also how to re-scale all the images to fit properly in game. I was able to create one working jar file with seperate folder for images except for one more thing.. I also have an xml fileI that has information in regards to layout of each board. the jar file won't use the xml file inside the jar file. So, my game still requires two files... jar file + xml file. How do i make the program read the xml file from inside the jar file?
I wouldn't mind posting my code, but with 3 classes and a xml file it would be a challenge. I tried putting attachments in a message but i don't think it's possible here.
Any advise with the xml issue?
- 04-27-2012, 06:29 AM #6
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 762
- Rep Power
- 14
Re: Creating Jar file with eclipse
I think you can always use the Class.getResourceAsStream() method to read resources. This allow you to read whether the resource inside a jar or not.
Website: Learn Java by Examples
Similar Threads
-
Creating executable jar file in Eclipse
By N00Bie in forum New To JavaReplies: 25Last Post: 06-18-2011, 04:43 AM -
Eclipse and creating .jar file
By wantakill in forum EclipseReplies: 11Last Post: 09-05-2010, 12:51 AM -
creating war file in eclipse
By pelegk1 in forum EclipseReplies: 3Last Post: 05-24-2010, 05:28 AM -
Creating .xml files in eclipse
By lheebhee in forum EclipseReplies: 1Last Post: 11-17-2009, 07:48 AM
Bookmarks