如何从 Oracle Forms 6i 调用 Java 对象/函数?

发布于 2024-11-04 19:57:09 字数 402 浏览 5 评论 0原文

我正在开发一个遗留项目,该项目使用 Oracle Forms 6i(是的,我知道它很旧)从 PLL 库调用 C++ 函数。

现在我们需要使用 Java 而不是 C++,因此我们需要从 Oracle Forms 调用 Java(对象/类/方法)。

我知道这是一个具有挑战性的主题,但如果有人可以提供一个执行以下操作的简单示例,我会非常高兴:

  • 从 Java 类调用方法,传递 int 变量(在 PL/SQL 内)
  • 在 Canvas 中打印返回值执行该函数的。

一个基本的例子,也许 Hello World 是理想的。

我了解一些 PL/SQL,但我不是 Oracle Forms 开发人员;请耐心听我说。

如果这是不可能的,你能给我指出一些其他的选择吗?

I am working on a legacy project that is using Oracle Forms 6i (yes, I know its old) to call C++ functions from a PLL library.

Now we need to use Java instead of C++, therefore we need to call Java (Object/Class/Method) from Oracle Forms.

I know its a challenging subject, but I would be really happy if someone could provide a simple example that does the following:

  • Invoking a method from the Java class, passing a int variable (within PL/SQL)
  • Printing the returned value in the Canvas that executed the Function.

A basic example, perhaps a Hello World would be ideal.

I know some PL/SQL, but I am not a Oracle Forms developer; please bear with me.

If this is not possible, could you point me to some other alternatives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

各自安好 2024-11-11 19:57:09

好吧,在通过互联网进行深入查找后,我发现了一个非常好的资源(不过是西班牙语):Elias 博客关于Oracle Forms 和 Java

我使用:

  • Oracle Forms 6i
  • JDK 1.6

通过这个我成功创建了 hello world 示例:


配置 PATH 环境变量:

  • 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


添加到 CLASSPATH

  • FORMS_HOME\TOOLS\common60\JAVA\IMPORTER.JAR (在我的例子中 FORMS_HOME 是 C:\orant)
  • PATH_TO_YOUR_JAR\NAME_OF_JAR.jar

创建 Java 程序

  1. < p>用你的IDE创建一个简单的java程序,以下是我的:

    公共类 HiWorld{        
      私人字符串 hi =“你好世界!”;
    
      公共字符串 getHi(){
        返回这个.hi;
      }
    
      公共字符串 getMultiply(int a, int b){
        返回“”+a*b;
      }
    
      公共静态无效主(字符串参数[]){            
        HiWorld hm = new HiWorld();
        System.out.println(hm.getHi());
        System.out.println(hm.getMultiply(5,10));                
      }
    }
    
  2. 将其导出到 Jar 文件(路径必须是您在 CLASSPATH 环境变量中放入的路径。

将类导入到 Forms

在 Oracle Forms 中创建一个新项目,并创建一个画布,在画布中使用文本和按钮。按钮的名称: TEXT_HI_WORLD.

单击菜单:程序 > 导入 Java 类

如果一切正常,则会出现一个新窗口,显示该类所在的包,您可以对其进行扩展,直到导入 HiWorld 类

。程序单元现在将有两个文件:

  • HIWORLD(规范)
  • HIWORLD(主体)

这是自动生成的文件,需要使用该类

然后返回到画布,右键单击按钮并选择 Thrigger。当按下按钮时,其编程将是:

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_hi
END;

现在执行程序并单击按钮!

希望这可以帮助对 Forms 没有太多了解的 Java 程序员与遗留系统集成! :D

Well, after an intensive lookup through the internet I came across a very good resource (in Spanish though): Elias blog about Oracle Forms and Java

I use:

  • 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 HiWorld{        
      private String hi="Hello World!";
    
      public String getHi(){
        return this.hi;
      }
    
      public String getMultiply(int a, int b){
        return ""+a*b;
      }
    
      public static void main(String args[]){            
        HiWorld hm = 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_hi
END;

Now execute the program and click on the button! :)

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

哎呦我呸! 2024-11-11 19:57:09

我之前已经这样做过,并且使用一个简单的类应该可以工作,但是当您尝试开发更复杂的东西时,我建议从 VBean 类扩展,您可以在 oracle 的表单安装文件夹 (frmall.jar) 中找到该库。

I've done this before, and with a simple class this should work, but when you try to develop something more complicated, I recommend extend from the VBean class, you can find the library within oracle's forms installation folders (frmall.jar).

久隐师 2024-11-11 19:57:09
// el programa corregido.

public class HolaMundo {

private String hi= "Hey World!!!";

  public String GetHi(){
    return this.hi;
  }

public static void main(String args[]){

    HolaMundo  hm = new HolaMundo();
    System.out.println(hm.GetHi());

  }
}
// el programa corregido.

public class HolaMundo {

private String hi= "Hey World!!!";

  public String GetHi(){
    return this.hi;
  }

public static void main(String args[]){

    HolaMundo  hm = new HolaMundo();
    System.out.println(hm.GetHi());

  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文