Plüss   Aplulogo      Print Text 
© 2021, V10.4

Standard installation of JavaOC/JavaOCW:

  1. Download the latest version from

  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 with some editor, e.g. notepad. A suggestion is:


    class MyFirst
        int items = 1234;
        double price = 2.55;
        double toPay = items * price;

    Compile with javac 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,
    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:
    Number of public methods: 9

    Enumerating constructors of class 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.



There is no need of a main-method from a logical point of view. To run a program, just use a small operating system utility that creates an object instance.

How it works
JavaOC parses the command line and uses JNI (Java Native Interface) to create first a Java VM (Virtual Machine) and then an instance of the given Java class while passing the command line arguments to the constructor found by reflection.