Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between running jar file and exe?

If you have a small program, you can run jar file and it will work fine. But if you convert jar file into exe, you still need java to run your exe file, so what's the difference between them and why do some people convert jar to exe?

like image 435
Vegeta Avatar asked Jan 04 '15 19:01

Vegeta


2 Answers

An EXE is, ostensibly, an executable program that launches the local java to execute the bundle classes.

As you may know, on your computer you can associate certain file extensions with local programs. For example, .doc files with your word processor.

Similarly, .jar files can be associated with Java, so that Java can execute them. The jar file is considered "stand alone" if it has all of the necessary classes bundled within it, and a proper manifest pointing to the startup class.

So, by associating .jar with Java, clicking on it in your environment will launch Java with the given jar file.

An EXE doesn't need that association. It find java on its own with it's own launcher.

The next step is that you can actually bundle the JRE in to an EXE, so you don't even need to have the user install Java as a pre-requisite. But that's a different process.

like image 138
Will Hartung Avatar answered Sep 28 '22 04:09

Will Hartung


People commonly use Java executable wrappers for two reasons - 1. to simply deployment for environments without a JVM, and 2. To make sure the exact Java runtime used for developing the application gets used to run the JAR. However, the practice is not that much widespread.

like image 28
Monir Zaman Avatar answered Sep 28 '22 06:09

Monir Zaman