Wednesday, June 23, 2010

'java' Command

Description

Execute Java classes/applications

Technical Specification (partial)

    java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...]
-Dmyprop=myval set a system property. retrieval: System.getProperty("myprop");

Notes

  • Classpath Searching:
    1. JRE
    2. Environment Variable (classpath)
    3. Command-Line Classpath (overrides environment variable)
  • Directory Delimitor: unix '/', Mac '/', Windows '\'
  • Classpath Separator: unix ':', Mac ':', Windows ';'
  • Current Directory: '.'
  • First class found is the one used. Searching stops when first class is found.

Examples

bash script

javac -d build -sourcepath src src/com/bryanpugh/scjp/MyClass.java

ant

    <project basedir=".">
      <target name="">
        <mkdir dir="${basedir}/build"/> <javac srcdir="${basedir}/src" destdir="${basedir}/build"/>
      </target name="">
    </project>

No comments:

Post a Comment