How to generate an executable of a program made in Eclipse?

Asked

Viewed 5,630 times

6

I did a program for the company in which I work entirely on JOptionPane, just so the program would work just by opening real system windows (I thought it would be easier to run officially after the export than one I saw running through the Eclipse text box).

My code is 100% ready and functional, and Eclipse is not indicating any errors. But obviously, no other employee of the company has the Eclipse to keep opening the program for him. I need the program to be open by any computer, Windows or Mac. For that, I would need a version of the program on. exe (for Win) and . dmg (Mac).

Question 1: How do I create these executables? My operating system is Mac and Eclipse is Neon3.

Question 2: What will be the requirements necessary for future users of my software to run it? Just Java installed? Windows/Mac already come with the necessary programs?

1 answer

6


Question 1: How do I create these executables? My operating system is Mac and Eclipse is Neon3.

You can export a jar of your program in the eclipse by going to File > Export..., selecting the option from the list Runnable JAR file.

On the next screen, you select your class from the list Main of the project and a name for the jar. It is important that the project has already been executed in the eclipse, otherwise it will not appear in this list, because the eclipse creates some settings for each executed class that has a method main, and uses these to also create the jar.

In the example below, I’m creating a jar of my own Projectoteste, and the ClasseMain how the class starts the application:

inserir a descrição da imagem aqui

After that, the application will run from the jar, through 2 clicks. If you want, you can use the Launch4j, who packs the jar in a exe, and allows you to define various customization parameters such as maximum and minimum JRE version that the user should have to run your application, decorate with an icon, etc...

Question 2: What will be the requirements necessary for future users of my software to run it? Just Java installed? Windows/Mac already come with the necessary programs?

If you include all third-party libs in the project’s classpath, you no longer need anything from the user except to have the Java Virtual Machine (JRE) installed. Of course, it needs to use a version equal to or higher than the one you used to compile your application.

  • Excellent answer! I’m sure I’ll test everything now... But how do I know that all third party libs are being complicated together? How am I sure I’m using some third-party lib, at all? Hahaha, is that I’m a little bit novice yet...

  • @santosmarco_ looks at your project if you have something beyond JRE System Library. If not, nothing to worry about, if you do, they’re probably already added in the classpath, and if you look at the option marked in the print at Library handling, the IDE will already include for you automatically :)

  • 2

    Beauty! Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.