1

I finished a small program. What is the standard file type for the final application written with Java, so it can be run on any computer, easily and without any computer knowledge?

I've been told it's JAR, but Eclipse for example is an .exe file. What's the standard file type for big, normal applications in Java?

Are most applications distributed in JAR, or rather in .exe or something else?

AvivC
  • 133
  • 2
  • 8

4 Answers4

0

Serious desktop applications are packaged with platform-specific launchers, which are not written in Java. The launcher must first find out how to run the JVM installed on the system, and then pass it either the path to the executable JAR to run, or the complete classpath along with the name of the main class.

In other words, "it's complicated".

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
0

Most desktop applications are distributed using .jar files. A .exe is windows-specific, and non-portable across different operating systems. It's easy to find installers (or "launchers") that will simplify the distribution of a Java program in other platforms, but anyway you'll find that .jar files are the usual packaging mechanism.

If you have a small, simple Java program the easiest approach to distribute it would be to pack it in a .jar, making sure to make it executable. And remember, the computer where your code is expected to run must have installed some version of Java, be it JRE or JDK.

Community
  • 1
  • 1
Óscar López
  • 232,561
  • 37
  • 312
  • 386
0

Desktop java applications are usually distributed as jar files. JRE can launch a runnable jar file using -jar param.

Dario
  • 548
  • 1
  • 7
  • 14
0

You have one of several options:

1 - Create an executable jar file. By providing information in a manifest within the jar file users can simply execute the jar file by however system-dependent means exist for their OS.

2 - Write a batch file or shell script to invoke the JRE against your jar file (and specify command line parameters for, eg: the main class, the classpath, JVM options, etc.)

3 - Use a tool like jexepack or jsmooth to wrap your Java code within a native executable. I've only ever used these to create Windows binaries - there may be other options for other platforms but shell scripts are typically easier to work with here.

Pedantic
  • 5,032
  • 2
  • 24
  • 37