Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a Windows .exe (standalone executable) using Java/Eclipse?

Tags:

I'm new to the programming scene. Been working with C++ for about 5 months now, and have decided I want to start getting into Java. I'm using Eclipse as my IDE, and obviously Java for the language. I'm trying to write a simple HelloWorld application, which can be run through a command prompt executable.

In Visual Studio, it seems it's rather easy to create an executable. All I've ever had to do is use a pull down arrow and choose Release, and then run my build. The purpose of wanting to be able to write/run Java in command prompt is so that I'm able to practice some of the language basics before I go in full force with Swing.

So bottom line, what is the easiest way to create a command prompt .exe written with Java?

Thanks in advance!

like image 647
Skizz Avatar asked Apr 19 '11 16:04

Skizz


People also ask

Can you make exe with Java?

Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executable files.


1 Answers

Java doesn't natively allow building of an exe, that would defeat its purpose of being cross-platform.

AFAIK, these are your options:

  1. Make a runnable JAR. If the system supports it and is configured appropriately, in a GUI, double clicking the JAR will launch the app. Another option would be to write a launcher shell script/batch file which will start your JAR with the appropriate parameters

  2. There also executable wrappers - see How can I convert my Java program to an .exe file?

See also: Convert Java to EXE: Why, When, When Not and How

like image 151
no.good.at.coding Avatar answered Sep 22 '22 18:09

no.good.at.coding