2

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.

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
user2158386
  • 25
  • 1
  • 2
  • 6

6 Answers6

6

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.)

Michael Berry
  • 70,193
  • 21
  • 157
  • 216
2

You need to create a .jar file from your project. On windows normally with double click those files get executed if a java virtual machine is installed.

There are solutions to wrap an .exe file around your .jar, but I don't know how good they are so I can't suggest anything.

LtWorf
  • 7,286
  • 6
  • 31
  • 45
1

Java executables are runnable .JAR files. You need to export as Runnable Jar.

In Eclipse:

  1. Right click on your project
  2. Export
  3. Export...
  4. Runnable JAR file
Simon Arsenault
  • 1,777
  • 17
  • 35
0

You would have to use chmod in the command line. This argument can change the permission of the file. It depends on three groups. Reading, writing, and executing can all be altered using this argument.

lancer
  • 133
  • 1
  • 3
  • 11
0

If you want an IDE agnostic solution, go for launch4j

Micha Wiedenmann
  • 19,979
  • 21
  • 92
  • 137
Jean Waghetti
  • 4,711
  • 1
  • 18
  • 28
0

like in ohter replies mentioned you need to create a jar file witch packages all your compiled classes. while exporting from eclipse you can optionally export the dependecies that your project needs to run.

if you want to create an exe file you can use some software witch packages/wraps your jar(s) into an executable file. you can try jsmooth, it provides several exe wrappers and has the ability to integrate your jar an its dependencies into one single file witch you can distribute and will be per click executed.

A4L
  • 17,353
  • 6
  • 49
  • 70