An often discussed topic is Java in Oracle Forms. There are various sites out there that explain how to build and deal with PJCs and Beans. Rarely covered is some basic functionality Forms has builtin since it's on the web (6i). That's the Java-Importer. Basically you have the possibility to use Java not just on Client side (with PJCs and Beans) you also are able to use Java via your frmweb process on the application Server. I recently needed it - once again. I tried to complete the implementation of the CELLWRAPPER parameter in the Reports Server (see previous post). It should be enough to put the file in the REPORTS_PATH, but that DOES NOT WORK . So I tried to get the workingDirectory, and found out that the easiest way is to use the Java System Class. First import the Java Class within your Formsbuilder:
  • Program -> Import Java Classes
  • enter "java.lang.System" as in "Import Classes"
  • Press "Import"
This few steps created a complete PL/SQL Wrapper for the java System Class. Now it's an easy task to get the user-directory (a bit reading of the java-doc) with:
SYSTEM.getProperty('user.dir')
Especially when using Java you need a better exception handling here's an rudimentary example of this:
BEGIN

  MESSAGE (SYSTEM.getProperty('user.dir'));
  PAUSE;
  
-- just an example, of course some better errorhandling should be done here
EXCEPTION
 -- important that you handle JAVA_ERROR AND EXCEPTION_THROWN
 -- you could even do a better handling by importing the Exception class
 WHEN ORA_JAVA.JAVA_ERROR then 
      MESSAGE('Java Error occured: '||ORA_JAVA.LAST_ERROR);
      PAUSE;
 WHEN ORA_JAVA.EXCEPTION_THROWN then                    
       MESSAGE('Java Exception occured');                  
       PAUSE;
 WHEN OTHERS THEN
       MESSAGE('others occured....');
       PAUSE;
END;
Have fun! Let me know if anybody needs more examples!