how to create .exe file in java?

Asked on February 27, 2015
how to create .exe file java? Is jar file can be called executable file in java?

Replied on February 27, 2015
Creating .exe is not good practice in Java. Java provides JAR file which is also executable by double click. There are many advantage of JAR file.
From oracle site,

The JAR file format provides many benefits:

Security: You can digitally sign the contents of a JAR file. 
Decreased download time: If your applet is bundled in a JAR file, the applet's class files and associated resources can be downloaded to a browser in a single HTTP transaction without the need for opening a new connection for each file.
Compression: The JAR format allows you to compress your files for efficient storage.
Packaging for extensions: The extensions framework provides a means by which you can add functionality to the Java core platform, and the JAR file format defines the packaging for extensions. 
Package Sealing: Packages stored in JAR files can be optionally sealed so that the package can enforce version consistency. Sealing a package within a JAR file means that all classes defined in that package must be found in the same JAR file.
Package Versioning: A JAR file can hold data about the files it contains, such as vendor and version information.
Portability: The mechanism for handling JAR files is a standard part of the Java platform's core API.

But if we still want to create .exe file, we can use some tools.

JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself.

JexePack is a command line tool (great for automated scripting) that allows you to package your Java application (class files), optionally along with its resources (like GIF/JPG/TXT/etc), into a single compressed 32-bit Windows EXE, which runs using Sun's Java Runtime Environment. Both console and windowed applications are supported.

Write Answer

©2024 | Privacy Policy | Contact Us