how can I create executable file for the program written on Java?

11,066

Solution 1

  1. Export .jar in eclipse. (how to)
  2. Use JSmooth (info) to make an .exe file. (how to)

Solution 2

  1. Create a 1-line metafile to specify which class the JVM should look for to start with the main(String[]) method.

  2. Run the command jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]

  3. You have an executable jar file - type in "java -jar jarfileName" or, directly "jarfileName" at your prompt. On windows, you can also double click on the jar file logo/name to get it started.

Good wishes, - M.S.

PS: Here is the link to a more detailed tutorial: http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html

Solution 3

You didn't mention what platform you are using. There are 2 ways I can think of.

The easiest way is for you to create a *.bat file (in Windows) that contains the java YourApp command line.

If you want to create a more fancy installer and executable, you can use NSIS script to do so. Since you are using eclipse, consider trying EclipseNSIS to generate the NSIS script, which is much faster and easier than writing it yourself from ground up.

Solution 4

The best answer for this situation is to launch the app. using Java Web Start. JWS can not only create desktop and start menu launch items, but provides automatic updates, cross-platform compatibility and much more.

Share:
11,066
rookie
Author by

rookie

Updated on July 30, 2022

Comments

  • rookie
    rookie over 1 year

    everyone, how can I create executable file for the program written on Java in Eclipse Helios? I mean to create small icon to be able start program only by double-clicking on its icon, thanks in advance edited I mean executable for Windows

  • Ilya Saunkin
    Ilya Saunkin almost 13 years
    .bat on windows and .sh on *nix
  • limc
    limc almost 13 years
    You can create a file in Windows, then rename the extension to ".bat". That's it. You will notice the icon automatically change. Double clicking it will execute it, so you want to right click on it, then "edit" that will open that bat file in a notepad. Then type it your java command and save it.
  • user unknown
    user unknown over 12 years
    Can you extract the jar from the exe, if you like to use it on a different OS?