Home » Developer & Programmer » Forms » How to call a java function from Oracle forms? (oracle forms 6i)
How to call a java function from Oracle forms? [message #549000] Tue, 27 March 2012 08:01 Go to next message
nrupa
Messages: 3
Registered: March 2012
Location: ahmedabad
Junior Member
Hi
I am new to Oracle Forms..
I am having Oracle 9.2.0.1.0 client in my PC and jdk version is 1.6

I had configured below tools in my PC. (windows 2000)
I am having Oracle 9.2 with Oracle Forms Builder 6i


How to call a java function from Oracle forms?
Can you give me the code samples and how to integrate those thing?

Thanks
Re: How to call a java function from Oracle forms? [message #549008 is a reply to message #549000] Tue, 27 March 2012 08:21 Go to previous message
owais_baba
Messages: 289
Registered: March 2008
Location: MUSCAT
Senior Member



·oracle Forms 6i
·JDK 1.6

With this I managed to create the hello world example:

Configure PATH environment variables:·

C:\PATH_TO_JAVA\Java\jdk1.6.0\bin;
C:\PATH_TO_JAVA\Java\jdk1.6.0\jre\bin;
C:\PATH_TO_JAVA\Java\jdk1.6.0\jre\bin\client;

Ex: PATH_TO_JAVA = C:\Program Files

Add to CLASSPATH·


FORMS_HOME\TOOLS\common60\JAVA\IMPORTER.JAR (In my case FORMS_HOME was C:\orant)

·PATH_TO_YOUR_JAR\NAME_OF_JAR.jar

Create Java Program

1.Create with your IDE a simple java program, following is mine:
     public class HolaMundo { 
           private String hi=
           "Hey World!!!";
      public String GetHi(){
            return this.hola;
  } 
      public String getMultiply(int a, int b){
            return ""+a*b;
  }
     public static void main(String args[]){
            HiWorldhm = new HiWorld();
            System.out.println(hm.GetHi());     System.out.println(hm.getMultiply(5,10));
 }
}


2.Export it to Jar file (Path has to be the one you put in CLASSPATH environment variable.

Import the classes to Forms

Create a new project in Oracle Forms and also create a Canvas, in the canvas use a Text and a Button. The name of the button: TEXT_HI_WORLD.

Following click on the Menu: Program > Import Java Classes

If everything went Ok then there will be a new window that will show you the package where the Class is, you extend it until there is the HiWorld class. Import it.

In Program Unit now there will be two files:

·HIWORLD (Specification)
·HIWORLD (Body)

This are files generated automatically and needed
to use the class.

Then go back to the canvas, right click on the Button and select the Thrigger WHEN-BUTTON-PRESSED, the programming of this will be:
   DECLARE
         v_wb      ORA_JAVA.JOBJECT;
         v_hi      VARCHAR2(20);
   BEGIN
         v_wb := hiworld.new();
         v_hi:= hiworld.getHi(v_wb);
         :TEXT_HI_WORLD := v_hiEND;


Now execute the program and click on the button! Smile

Hope this helps Java programmers with no much of knowledge on Forms to integrate with legacy systems! Very Happy

[Updated on: Tue, 27 March 2012 08:25]

Report message to a moderator

Previous Topic: pick single value from range (merged 2)
Next Topic: sequence number to be diplayed in form
Goto Forum:
  


Current Time: Tue Sep 23 09:31:19 CDT 2014

Total time taken to generate the page: 0.13995 seconds