Results 1 to 6 of 6
  1. #1
    Danieldcc is offline Member
    Join Date
    Sep 2010
    Posts
    83
    Rep Power
    0

    Default 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?

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default 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)

  3. #3
    Danieldcc is offline Member
    Join Date
    Sep 2010
    Posts
    83
    Rep Power
    0

    Default 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"));

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default 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)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Danieldcc is offline Member
    Join Date
    Sep 2010
    Posts
    83
    Rep Power
    0

    Default 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?

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default 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.

Similar Threads

  1. Creating executable jar file in Eclipse
    By N00Bie in forum New To Java
    Replies: 25
    Last Post: 06-18-2011, 03:43 AM
  2. Eclipse and creating .jar file
    By wantakill in forum Eclipse
    Replies: 11
    Last Post: 09-04-2010, 11:51 PM
  3. creating war file in eclipse
    By pelegk1 in forum Eclipse
    Replies: 3
    Last Post: 05-24-2010, 04:28 AM
  4. Creating .xml files in eclipse
    By lheebhee in forum Eclipse
    Replies: 1
    Last Post: 11-17-2009, 06:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •