Jarx for developers

You can add Jarx to your own Java programs and provide a better experience to the user.

Disadvantages of distributing just the JAR file

You might think distributing only a JAR file to Windows users is enough. Unfortunately, a JAR file has some serious drawbacks:

  1. Java might not be installed. The JAR file just won't work and users will think your program is broken. You can mention in the manual that the user has to download Java, but many users don't read the manual and don't know how to install Java.
  2. Even when Java is installed, the .jar file extension association can be "stolen", e.g. when installing an unzip program.
  3. Currently, JAR files have a standard Windows document icon, which doesn't look like an executable. So even when Java is set up right, the user looking for an executable might skip the JAR file.

Jarx overcomes all these problems.

When you distribute a Java 1.1 program, Jarx has even more advantages:

  1. Java 1.1 JVM's don't read the manifest file. Jarx does, even with a Java 1.1 JVM installed.
  2. Jarx will first try to load a Sun JVM and when that fails, it loads the Microsoft VM. Microsoft's VM still has a large installed base, so Jarx does not force users to download the JRE when it is not really necessary.

There are three ways to use Jarx together with your Java software

  1. Associate .jar with jarx.

    By associating the .jar file extension with the jarx program, every JAR file will become "executable". The JAR file can be double clicked, selected from the Start menu etcetera. To have a executable JAR file, it must contain a manifest file. You can find more information about the manifest file in the JAR File Specification.

  2. Associate .jarx with jarx.

    A file with the .jarx file extension is a configuration file, just like the manifest file. See below for the format. In this file you can describe which JAR file to load and which class contains the main method to execute. You can start your Java software by double clicking a jarx configuration file.

  3. Associate your own extension with jarx.

    If your Java program is document-oriented, you can associate your own file extension with jarx. Jarx will then execute your JAR file with the document as a parameter. A document can be anything, including, for example, an image. You can do this by making a default.jarx file in the same directory as the Jarx executable. See below for more information about the .jarx file format.

The .jarx file format

The Jarx configuration file, with the .jarx extension, gives the Jarx program information about which JAR file to load and which class to execute.

The Jarx configuration file is a text file. Every line starts with a name, followed by a colon ':', folowed by one or more spaces, followed by the value.

NameValue
jar-file(Relative) location of the JAR file.Obligatory
main-classThe full class name of the class containing the static void main method, just like in a manifest.mf fileObligatory
class-pathThe classpath. When left out, the JAR file will be the only entry in the classpath.Optional
version-minMinimum supported Java version. When the installed version is older, the user will be asked to download the newest version. The value must have the format <number>.<number>.Optional

An example Jarx configuration file is:

jar-file: GameOfLife.jar
main-class: org.bitstorm.gameoflife.StandaloneGameOfLife
version-min: 1.1

You can download the Game of Life to see how Jarx works with other software. On the Game of Life source code page, you can find an installer script for the free NSIS installer program.

Download

You can download the plain jarx.exe or download and install the end user installer from the Jarx web page:

Open Source

Jarx is Open Source and licensed under the MIT license.

You can fork the code at GitHub:

https://github.com/edwinm/Jarx

License

	Copyright (c) 2004 Edwin Martin

	Permission is hereby granted, free of charge, to any person
	obtaining a copy of this software and associated documentation
	files (the "Software"), to deal in the Software without
	restriction, including without limitation the rights to use,
	copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the
	Software is furnished to do so, subject to the following
	conditions:

	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
	OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
	HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
	WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
	OTHER DEALINGS IN THE SOFTWARE.

For further questions, please contact Edwin Martin <edwin@bitstorm.org>.