User Tools

Site Tools


java

Java

Running

Run a class which has a main()

$ java net.myapp.MyApp

Run a jar directly

$ java -jar MyApp.jar

Building

Compiling

JAVAC_CLASSPATH=
PROGRAM_MAIN=net/myapp/MyApp.java
 
cd src
 
# add external libraries to classpath
for i in $(find ../lib -type f -iname '*.jar') ; do
    JAVAC_CLASSPATH=${JAVAC_CLASSPATH}:${i}
done
 
javac -d $TMPDIR/bin -classpath ".:${JAVAC_CLASSPATH}" $PROGRAM_MAIN

java-doc

$ javadoc -d doc/api -sourcepath src -private -subpackages net.myapp

Distribution

jar

Manifest.txt
Manifest-Version: 1.0
Main-Class: net.myapp.MyApp
Class-Path: lib/mysql-connector-java-5.1.11-bin.jar data/i18n/
Sealed: true
Name: net/myapp/
Specification-Title: Example App
Specification-Version: 1.0
Specification-Vendor: Me
Implementation-Title: net.myapp
Implementation-Version: 1.0
Implementation-Vendor: Me
SplashScreen-Image: data/images/splash.png
$ jar cfm MyApp.jar Manifest.txt -C bin/ . data/images/splash.png

"Everything in one JAR"

Having external libraries in a JAR is not (yet) supported by the java class-loader.

Although it's not always useful having ALL files in one JAR, here are some possibilities:

java.txt · Last modified: 2010-06-19 23:55 CEST (external edit)