2.2 Execution Control of Java Applications

In the Java 2 Platform, Standard Edition (J2SE) environment, you develop Java applications with a main() method, which is called by the interpreter when the class is run. The main() method is called when you enter the following command on the command-line:

java classname

This command starts the Java interpreter and passes the desired class, that is, the class specified by classname, to the Java interpreter. The interpreter loads the class and starts running the application by calling main(). However, Java applications within the database do not start by a call to the main() method.

After loading your Java application within the database, you can run it by calling any static method within the loaded class. The class or methods must be published before you can run them. In Oracle Database, the entry point for Java applications is not assumed to be main(). Instead, when you run your Java application, you specify a method name within the loaded class as your entry point.

For example, in a standard Java environment, you would start the Java object on the server by running the following command:

java myprogram

where, myprogram is the name of a class that contains the main() method. In myprogram, main() immediately calls mymethod() for processing incoming information.

In Oracle Database, you load the myprogram.class file into the database and publish mymethod() as an entry-point. Then, the client or trigger can invoke mymethod() explicitly.