Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an executable file in java? [duplicate]

Tags:

java

eclipse

I did my project in Eclipse. I have *.java, .project, .classpath and *.class files in my Eclipse workspace. How do I create an executable?now.

like image 695
user2158386 Avatar asked Jul 24 '26 21:07

user2158386


1 Answers

Eclipse will build an executable jar file for you, which is run with Java (java.exe if you're on windows) to launch your application. On a machine correctly set up with Java installed, double clicking an executable jar should run the program.

If you want an exe, then there are ways to do it that will generally wrap the jar file (and sometimes the JDK.) However, first ask yourself why you're doing it this way - often it's just a habitual desire to have an exe, without any great technical reason. All you're really doing through this is taking a cross-platform executable, and making it only work on Windows.

If you're distributing your application and your users expect an exe, then consider building platform dependant installers for each OS you wish to support, but leaving the jar file in tact. The average user will never usually need to touch it directly if your installer places shortcuts in the correct locations, they'll only ever need to run the installer directly (so your application file format becomes irrelevant, just an implementation detail as far as they're concerned.)

like image 125
Michael Berry Avatar answered Jul 26 '26 10:07

Michael Berry