Java is an object-oriented programming language developed by Sun Microsystems that is commonly used for web development and other programming needs. It is beyond the scope of this section to describe Java in detail. Numerous third-party books and electronic resources are available. The Java website (https://www.oracle.com/java/technologies/) may be useful.
The IDL-Java bridge allows you to access Java objects within IDL code. Java objects imported into IDL behave like normal IDL objects. See Creating IDL-Java Objects for more information. The IDL-Java bridge allows the arrow operator (->) to be used to call the methods of these Java objects just as with other IDL objects, see Method Calls on IDL-Java Objects for more information. The public data members of a Java object are accessed through GetProperty and SetProperty methods, see Managing IDL-Java Object Properties for more information. These objects can also be destroyed with the OBJ_DESTROY routine, see Destroying IDL-Java Objects for more information.
The bridge also provides IDL with access to exceptions created by the underlying Java object. This access is provided by the IDLJavaBridgeSession object, which is a Java object that maintains exceptions (errors) during a Java session, see The IDLJavaBridgeSession Object for more information.
Note: Visual Java objects cannot be embedded into IDL widgets.
Java Runtime Environment Requirements
IDL supports version 1.7 and greater of the Java runtime environment.
Note: On Mac machines, the version of Java installed along with the operating system should be sufficient, whatever its version number.
Review the following terms before trying to understand how IDL works with Java objects:
Java Virtual Machine (JVM) - A software execution engine for executing the byte codes in Java class files on a microprocessor.
Java Native Interface (JNI) - Standard programming interface for accessing Java native methods and embedding the JVM into native applications. For example, JNI may be used to call C/C++ functionality from Java or JNI can be used to call Java from C/C++ programs.
Java Invocation API - An API by which one embeds the Java Virtual Machine into your native application by linking the native application with the JVM shared library.
Java Reflection API - Provides a small, type-safe, and secure API that supports introspection about the classes and objects. The API can be used to:
- Construct new class instances and new arrays
- Access and modify fields of objects and classes
- Invoke methods on objects and classes
- Access and modify elements of arrays
IDL-Java Bridge Architecture
The IDL-Java bridge uses the Java Native Interface (JNI), the reflection API, and the JVM to enable the connection between IDL and the underlying Java system.
The IDL OBJ_NEW function can be used to create a Java object. A Java-specific class token identifies the Java class used to create a Java proxy object. IDL parses this class name and creates the desired object within the underlying Java environment.
The Java-specific token is a case-insensitive form of the name of the Java class. Besides the token, the case-sensitive form of the name of the Java class is provided because Java itself is case-sensitive while IDL is not. IDL uses the case-insensitive form to create the object definition while Java uses the case-sensitive form.
After creation, the object can then be used and manipulated just like any other IDL object. Method calls are the same as any other IDL object, but they are vectored off to an IDL Java system, which will call the appropriate Java method using JNI.
The OBJ_DESTROY procedure in IDL is used to destroy the object. This process releases the internal Java object and frees any resources associated with it.