8 Replies - 30520 Views - Last Post: 15 December 2010 - 04:49 AM Rate Topic: -----

#1 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 02:38 PM

Alright so I've never really used eclipse before and I was never taught how to create executable jar files so I decided I'd use the feature in Eclipse. However, I cannot seem to get the feature to work. I go to the export option, select executable jar file, select the main class and path, and click finish. The outcome: a jar file that looks like it should work. But when I click on the jar, it does nothing. The size of the jar seems way too small--60.9 kb...

I also have a resource foler within the bin (the folder with class files) if that makes any difference.

The program runs fine when I run it within Eclipse though.

So I have no idea why it's not working and no good answers on Google either. Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Creating an Executable Jar Files in Eclipse

#2 cdog5000  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 79
  • Joined: 31-October 09

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 02:49 PM

View Postbcranger, on 14 December 2010 - 01:38 PM, said:

Alright so I've never really used eclipse before and I was never taught how to create executable jar files so I decided I'd use the feature in Eclipse. However, I cannot seem to get the feature to work. I go to the export option, select executable jar file, select the main class and path, and click finish. The outcome: a jar file that looks like it should work. But when I click on the jar, it does nothing. The size of the jar seems way too small--60.9 kb...

I also have a resource foler within the bin (the folder with class files) if that makes any difference.

The program runs fine when I run it within Eclipse though.

So I have no idea why it's not working and no good answers on Google either. Any help would be appreciated.

Make sure the correct Class to be ran is being selected. If it is a Command Prompt program most likely you will have to open the program using the command-line ("java -jar <name of jar>")

If it is neither of those then try copying the resource folder to the folder that the jar file is in, end result should look like:
Posted Image
Was This Post Helpful? 1
  • +
  • -

#3 jumptrooper  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 234
  • Joined: 19-August 10

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 03:45 PM

If you want a jar file you can just double click and have run, this is the sequence:
1) Highlight the appropriate file/project
2) File -> Export
3) Choose "Runnable JAR file" -> Next
4) Make sure the right project is selected under the "Launch Configuration" dropdown and select "Package required libraries into generated JAR file" under the "Library Handling" section and make sure it's going to the correct export destination.
5)click Finish

Now you should have the jar file in the destination you told it to export to. Double click it and it should run.
**HOWEVER** If this is a command line program it will not run. To run a command line program, after doing the above steps, open the command prompt, cd to the correct directory, and execute it by typing java -jar name_of_file.jar
Was This Post Helpful? 1
  • +
  • -

#4 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 03:49 PM

Thanks for the replies!

I've tried both suggestions and it's still not working...I remember I got it to work for a different program a while back but I just can't figure it out on this one...
Was This Post Helpful? 0
  • +
  • -

#5 m-e-g-a-z  Icon User is offline

  • Winning
  • member icon


Reputation: 496
  • View blog
  • Posts: 1,453
  • Joined: 19-October 09

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 05:31 PM

Probably a good idea to do it by hand - look at this. Something pbl usually says. :)
Was This Post Helpful? 1
  • +
  • -

#6 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2873
  • View blog
  • Posts: 11,032
  • Joined: 15-July 08

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 07:26 PM

View Postbcranger, on 14 December 2010 - 04:49 PM, said:

Thanks for the replies!

I've tried both suggestions and it's still not working...I remember I got it to work for a different program a while back but I just can't figure it out on this one...


Ok, run it via the command line and see what it does. Does it really do nothing? Or does it give you an error? What's happening? You cannot just say "It doesn't work".

And if it's a GUI, did you remember to set the JFrame visible (setVisible(true))? That's another common error.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 10:16 PM

View Postm-e-g-a-z, on 14 December 2010 - 06:31 PM, said:

Probably a good idea to do it by hand - look at this. Something pbl usually says. :)

Do it by hand son... but I must admit I used the Eclipse feature of "Export---> to executable Jar file" and it works
Just have to use WinRar after to remove useless crap
Was This Post Helpful? 1
  • +
  • -

#8 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Creating an Executable Jar Files in Eclipse

Posted 14 December 2010 - 11:03 PM

Sorry, but I've never learned to do it by hand...

To do it by hand, are you supposed to use the command prompt thing on your computer, like CMD for Windows 7?
Was This Post Helpful? 0
  • +
  • -

#9 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2873
  • View blog
  • Posts: 11,032
  • Joined: 15-July 08

Re: Creating an Executable Jar Files in Eclipse

Posted 15 December 2010 - 04:49 AM

Yes, and as a programmer, learn to love it. I typically have 3 or 4 Terminals open in every session that I program. Though you may use them more in *NIX, I still use them in Windows, when I'm on a Windows machine. Just push the "Start" button and type "cmd" and push enter.

Some important commands other than "java" and "javac" are:
cd - change directory
mkdir - make directory
del - delete something (file or directory)
dir - lists all the files and folders in the directory

And there are MANY more. These are just the important ones:
http://ss64.com/nt/

P.S. If you like the Linux Terminal commands better, you can create aliases so that all the Linux commands work on Windows.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1