1

I have java class in which I am doing some business functionality, now what I want is a standalone file so that user dont need to write java command to execute it but he can directly execute it as .exe file. Can anybody help me in this? I hope I was clear

Pulkit
  • 3,953
  • 6
  • 31
  • 55
  • 1
    It's a known question, already documented: http://stackoverflow.com/questions/147181/how-can-i-convert-my-java-program-to-an-exe-file – foch Dec 13 '13 at 11:14
  • Also check this. Same question. http://stackoverflow.com/questions/4330936/how-can-i-convert-a-jar-to-an-exe – A Paul Dec 13 '13 at 11:15

4 Answers4

3

I would recommend to create a JAR file of your Java classes.

JAR file can be executed with: java -jar filename.jar

For default installation in Windows, there will be a file association between JAR files and Java, such that one can double click on the jar file to execute it (i.e., it behaves like an exe file).

JanC
  • 345
  • 1
  • 6
2

First make a jar file and then wrap your jar file into .exe. There are plenty softwares available. Just google jar to exe

sanket
  • 789
  • 4
  • 16
2

Have a look at launch4j. It encapsulate a jar into a .exe.

It has a lot of other useful functionalities such as checking for the correct JRE version or giving download links in case Java is not installed.

Matthieu
  • 2,736
  • 4
  • 57
  • 87
  • but I have a java class which is using some other jar also say poi-3.9 jar. how to make it now executable now? – Pulkit Dec 13 '13 at 11:44
  • @Pulkit you can then use "jar-in-jar" embedding, as described in [that other question](http://stackoverflow.com/questions/8312909/java-create-jar-executable-with-dependant-jars-embedded) – Matthieu Dec 13 '13 at 11:48
0

in simple word make a jar and in manifest file put the entry point that is you swing main class which you want to run, Make sure you jar is correctly compiled with JRE version,

Pulkit
  • 3,953
  • 6
  • 31
  • 55