0

I wrote a JAVA program for my wife to compare coupons stacked with sales on different item sizes to save her time on her shopping-trip-planning. Now I need to put it on her computer in such a way that she can double-click something, and have the program run. I'm not finding anything good on the interwebs (like a decent step by step).

It is a simple program, one class with a nested class, and various imports of swing, awt, and text.

Since it's my wife's computer, I can make sure that she is running the appropriate JRE. Thanks in advance for any help.

user3277465
  • 23
  • 1
  • 6
  • Did you try to make executable jar file.? – Saif Jun 19 '14 at 04:34
  • Your question s OS specific: not the same on Linux than on Windows – Basile Starynkevitch Jun 19 '14 at 04:34
  • create batch file and add it into window service – Nirav Prajapati Jun 19 '14 at 04:35
  • The first search result for "java tutorial executable jar" is [Java Tutorail: Packaging Programs in JAR Files](http://docs.oracle.com/javase/tutorial/deployment/jar/), the third is [How to make an executable jar file?](http://stackoverflow.com/questions/5258159/how-to-make-an-executable-jar-file), and that is not counting questions already shouwn as related. – Oleg Estekhin Jun 19 '14 at 05:56
  • Right, I read through all those, so I must be doing something wrong, then. I get an executable jar, but when I double-click it, nothing happens. If I change the "open with" to javaw, or javaws, I get a cmd window to flash on the screen, and as best I can tell is can't find the main class (disappears really quickly). Must be a setting or option I don't have correct in the build process? – user3277465 Jun 19 '14 at 14:38
  • Looks like I get to choose between 2 "java platform (se) binary" to open the file, and one of them works fine. Operational now. Thanks to all. – user3277465 Jun 20 '14 at 03:41

4 Answers4

5

You can use Launch4j application. That convert executable jar file to windows native executable application.

You can also embed JRE with it so if JRE is not installed on machine the application will run.

you can also add some other mechanism to it also like loading image, icon, etc.

user3145373 ツ
  • 7,858
  • 6
  • 43
  • 62
2

I assume you are using Eclipse. In this website they given it very clearly for eclipse.

Create Executable files in eclipse

0

Export it to (or create a) executable Jar.

Most IDE's will do this (I think you have to dig around Eclipse a little) or take a look at Packaging Programs in JAR Files and Setting an Application's Entry Point if you want to do it by hand

Most GUI OS's will run the Jar via a double click.

You could also investigate generating a native executable wrapper, which will make the program "look" more familiar to the user, including launch4j or exe4j or Packaging a Java App for Distribution on a Mac depending on your target platform

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
0

Use NetBeans and simply 'Build' the jar file. This will produce an executable file within the 'dist' folder of your project.

Eclipse is the same however slightly more hidden.