Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Need help to export .jar file

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    53
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Need help to export .jar file

    I have created one program with GUI using Eclipse. I need to export it as a runnable .jar file. I do exactly as I seen on some tutorials.
    My problem is the following:
    Many of my buttons have ImageIcons. They have links to a Source Folder that I have in my project, where .jpg files of the Icons are located. The problem is that I do not find a way to make these icons visible after I run the .jar file.

    Here it is a piece of code having the methods I used to setIcons and how are the looking in my Eclipse Project.

    image.jpg

    Is there any problem that files are .jpg? Do I need to place them in another kind of folder?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,153
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Need help to export .jar file

    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Member
    Join Date
    Jul 2011
    Posts
    53
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Need help to export .jar file

    I tried to do like that but I only got nullpointer exceptions. I ended with creating JButton class and drawing each button there inside the paintComponent method. Like that I no longer needed any resource file.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,066
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Need help to export .jar file

    Creating images and buttons in the paintComponent method is not the way to do it. If your code is being executed from a jar file you should be using resources not disk files.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,600
    Thanks
    24
    Thanked 313 Times in 293 Posts

    Default Re: Need help to export .jar file

    How are you accessing the images?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Suggestions about best way to export/inport data to a .txt file
    By jhy2a in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: October 31st, 2013, 09:48 AM
  2. export statement
    By rajivsomayaji in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 17th, 2012, 09:23 AM
  3. Replies: 1
    Last Post: April 7th, 2011, 07:01 AM
  4. Export Excel which has more than 1 worksheet
    By rajesh_grs in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 22nd, 2011, 02:10 PM
  5. Export to excel
    By ebosysindia in forum File I/O & Other I/O Streams
    Replies: 7
    Last Post: May 14th, 2009, 06:25 AM