jump to navigation

Reference to command line java utilities February 29, 2008

Posted by lemonpress in 1 cat, dev environment installation.
trackback

see http://neptune.netcomp.monash.edu.au/JavaHelp/howto/jar.htm

create compressed library archive (JAR)

jar   cf   archive_name.jar   list-of-files

jar   cf   example.jar   One.java   Two.java   Three.java

jar   cf   example.jar   *.java

jar   cf   example.jar    *

create java executable

javac  * java     compile all Java source files in the current dir

javac   One.java  Two.java  Three.java

create an executable JAR

  • create a text file that lists the “main” class e.g. mainClass.txt Main-Class: Three
  • jar  cmf   mainClass.txt   example.jar   *.class

c -    with modifications to the manifest file
m-   name jar after main class as specified within mainClass.txt
f -    including everything that matches the pattern *class

run executable JAR from command line

java   -jar   example.jar

Options

- c      create new archive
- t       list table of contents for archive
- x      extract named (or all) files from archive
- u      update existing archive
- v      generate verbose output on standard output
- f      specify archive file name
- m    include manifest information from specified manifest file
- 0     store only; use no ZIP compression
- M    do not create a manifest file for the entries
- i       generate index information for the specified jar files
- C      change to the specified directory and include the following file
- -p preserve directory path

Comments»

No comments yet — be the first.