Unpack in any folder. You get the files javaoc.exe, javaocw.exe, readme.txt.
Copy javaoc.exe and javaocw.exe in a directory which is part of the path, typically c:\windows\system32.
Determine the current version of the Java Runtime Environment by typing java -version from a command shell.
Look for the home directory of this JRE, typically
c:\Program Files\Java\jreNNN, where NNN is the version.
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.
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:
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.
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
The usemain-option gives you a (restricted) backward compatibility with java resp. javaw. Try it with a program which contains a main-method.
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.