Featured Post

The great debacle of healthcare.gov

This is the first time in history when the president of the United States of America, or probably for any head of state around the world,...

Tuesday, November 6, 2007

The simplest way to create an executable jar in java

The simplest way to create an executable jar in java.

1. Create the MANIFEST.MF file. Add the Main-Class in the manifest file:
Main-Class: Main

2. Create the jar file
jar cvfm factor.jar MANIFEST.MF *.class com gnu

3. Execute the Main class from the executable jar
java -Xms512m -Xmx512m factor.jar

Note: The Class-Path: entry doesn't work, at least in jdk 1.4 as expected i.e. it doesn't load the jar file into the classpath. The Class-Path only inform the java command to search the libraries in the relative location from the current directory. So if the jar files can be found in the location mentioned in the Class-Path: entry, then it works

No comments: