Results 1 to 5 of 5
  1. #1
    Bread is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default [SOLVED]How do I export to a Jar?

    I have created a game for fun, and I'm having trouble exporting it to a jar file so I can place it on a webpage.
    It runs perfectly in eclipse however, on a webpage the jar file sits there with the Java logo waiting it load, which it never does.

    So I'm not sure if I should use just class files to place on the webpage.


    However, when I try to use the applet tag with code="Game.class" it only draws a black screen with none of the things from my other classes being loaded. So I'm not sure whether Eclipse is messed up, or if I don't know anything at all(Which is most likely the case).

    So can anyone help me seal my game into a jar? Or just get it on a blank HTML document for that matter.

    It can be found here:

    http://zrev.net/java.zip


    Thanks,

    Bread
    Last edited by Bread; 11-15-2010 at 01:03 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Your best bet is to create smaller experimental jars to test sub-portions of your program to find out just where the problem is -- to trouble shoot, and then when found, to post this small program here.

    My guess is that you're trying to treat resources such as images as if they were files, which may work in Eclipse but not in the Jar where you have to treat them as resources. If you use images or obtain files, try a simpler version of your program without this functionality just to see if it works.

    Luck!

  3. #3
    Bread is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    It worked perfectly, thank you very much! I replaced all the images with drawRect and it worked just the way it needs to.

    How would I go about adding images since it didn't work?

    Thanks again,
    Bread

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Use the ImageIO.read(InputStream input) method, and get your images not as files, but as resources via class's getResourceAsStream(...) method.

  5. #5
    Bread is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    I'll be sure to stick around this forum for awhile!

    I'll take a look at making my images into resources and post any troubles I have later on.


    Thanks for the help again Fubarable!


    -Bread

Similar Threads

  1. Export data to xls
    By trill in forum Advanced Java
    Replies: 5
    Last Post: 03-24-2011, 06:13 AM
  2. export to xml
    By karq in forum Advanced Java
    Replies: 0
    Last Post: 10-01-2010, 11:49 AM
  3. export eps
    By mr_empty in forum Java 2D
    Replies: 0
    Last Post: 04-25-2010, 09:40 AM
  4. Export jtable to csv
    By anilkumar_vist in forum New To Java
    Replies: 1
    Last Post: 02-08-2010, 08:25 AM
  5. Export to excel
    By nehaa in forum AWT / Swing
    Replies: 1
    Last Post: 04-30-2009, 03:44 PM

Posting Permissions

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