October 22, 2024
Chicago 12, Melborne City, USA
java

Oracle Forms Java Importer not detecting my JAR files


Currently, I am trying to implement a simple REST API trigger upon a button click on Oracle Forms.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.Serializable;

public class CatFactBean implements Serializable {
    private static final long serialVersionUID = 1L;

    // Method to get a random cat fact
    public String getCatFact() {
        try {
            String urlString = "https://catfact.ninja/fact";
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");

            // Set the User-Agent header
            connection.setRequestProperty("User-Agent", "Mozilla/5.0");

            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuilder content = new StringBuilder();

            while ((inputLine = in.readLine()) != null) {
                content.append(inputLine);
            }

            in.close();
            connection.disconnect();

            return content.toString();
        } catch (Exception e) {
            return "Error: " + e.getMessage();
        }
    }

    // Main method for testing the getCatFact method
    public static void main(String[] args) {
        CatFactBean catFactBean = new CatFactBean();
        String catFact = catFactBean.getCatFact();
        System.out.println("Cat Fact: " + catFact);
    }
}

This is the java code I am trying to run on my Oracle Forms application. I have compiled it into a jar and placed it inside K:\Oracle\Middleware\forms\java where all of the other jars reside for a manual installation of Oracle Forms.

jar files

My current CLASSPATH in my default.env are these:

CLASSPATH=K:\Oracle\Middleware\jlib\importer.jar;K:\Oracle\Middleware\jlib\frmbipc.jar;K:\Oracle\Middleware\forms\j2ee\frmsrv.jar;K:\Oracle\Middleware\forms\provision\frmconfig.jar;K:\Oracle\Middleware\jlib\ldapjclnt11.jar;K:\Oracle\Middleware\jlib\debugger.jar;K:\Oracle\Middleware\oracle_common\jlib\ewt3.jar;K:\Oracle\Middleware\oracle_common\modules\oracle.bali.share\share.jar;K:\Oracle\Middleware\jlib\utj.jar;K:\Oracle\Middleware\jlib\zrclient.jar;K:\Oracle\Middleware\reports\jlib\rwrun.jar;K:\Oracle\Middleware\forms\java\frmwebutil.jar;K:\Oracle\Middleware\forms\java\frmRest.jar;K:\Oracle\Middleware\forms\java\CatFactBean.jar

Following Oracle Forms Javaimport documentation,

The class browser lists all of the Java classes found on the CLASSPATH. The classes are ordered in
the same way that they are represented in the CLASSPATH.

This means that in Oracle Form Builder, when I would like to import the jars from the CLASSPATH, it would be visible. However it is not for my case. Am I doing something wrong here?

From Oracle Form Builder, I have tried to import the jar file name which is CatFactBean.jar or CatFactBean or another jar file I am trying to use is frmRest.jar or frmRest.getRest. I will keep getting the Exception occured: java.lang.ClassNotFoundException: frmRest.getRest.

java classes import

I was expecting all of the jar files listed in the CLASSPATH would be visible here.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video