JavaOC
 
 


Standard installation of JavaOC/JavaOCW:

  1. Download the latest version from www.aplu.ch/javaoc.

  2. Unpack in any folder. You get the files javaoc.exe, javaocw.exe, readme.txt.

  3. Copy javaoc.exe and javaocw.exe in a directory which is part of the path, typically c:\windows\system32.

  4. Determine the current version of the Java Runtime Environment by typing java -version from a command shell.

  5. Look for the home directory of this JRE, typically
    c:\Program Files\Java\jreNNN, where NNN
    is the version.

  6. Create a system environment variable jrehome, which points to this directory (info). Check from a newly opened command shell by typing set jrehome. Typically you get
    jrehome=c:\Program Files\Java\jreNNN.

  7. Try your first program without a main-method. You may proceed as follows: Create the source file MyFirst.java with some editor, e.g. notepad. A suggestion is:

    // MyFirst.java

    class MyFirst
    {
      MyFirst()
      {
        int items = 1234;
        double price = 2.55;
        double toPay = items * price;
        System.out.print(toPay);
      }
    }

    Compile with javac MyFirst.java and run with javaoc MyFirst resp. javaocw MyFirst.

  8. Inform you about the command line parameters by typing javaoc -h or javaoc -help. You get typically:

    JavaOC: Java Object Creator (Version nn - Date)
    Author: Aegidius Pluess, www.aplu.ch
    Usage: javaoc [-options] className [args...]

    Launch a Java Virtual Machine (JVM) and create an instance
    of given className using constructor with given arguments.

    Options are:
    -cp <class search path of directories>
    (replaces value of environment variable "classpath"
    the current path . is always included)
    -jrehome <home directory of installed JRE>
    (replaces value of environment variable "jrehome")
    -verbose enable verbose output
    -usemain: if main() is present, invoke it [with args]
    (instead of object creation)
    -h[elp]: show this text
    Illegal options are ignored.


  9. Try the verbose-option by typing javaoc -verbose MyFirst resp. javaocw -verbose MyFirst. You get typically


    Enumerating public methods of class MyFirst:
    hashCode
    getClass
    wait
    wait
    wait
    equals
    notify
    notifyAll
    toString
    Number of public methods: 9

    Enumerating constructors of class MyFirst:
    MyFirst()
    Number of constructors: 1



  10. The usemain-option gives you a (restricted) backward compatibility with java resp. javaw. Try it with a program which contains a main-method.

  11. In order to include JavaOC in your favorite IDE, follow the instructions how to set the options to run a program. Normally you may choose in the configuration options which program is used. Change java to javaoc resp. javaw to javaocw.

    JavaOC/JavaOCW uses the environment variable CLASSPATH but accepts also the option -cp or -classpath, which supersedes the value of the environment variable.


    The following example for JCreator gives you an idea how to proceed.

    ?