|
IDL Connectivity Bridges: Using the Connector Object |
|
The following Java example creates two arrays and passes them to IDL using the setIDLVariable method. An executeString command then multiplies the two arrays and getIDLVariable returns the result to the java application. The product of the array multiplication is printed to the command window.
| Example Code The file for this example, arrays_example.java, is located in the examples/doc/bridges/java subdirectory of the IDL distribution. |
Complete the following steps:
arrays_example.java in the location referenced above.
Run and enter cmd in the textbox.
cd command to change to the directory containing the arrays_example.java file. For a default Windows installation, the command would be: cd IDL_DIR\examples\doc\bridges\java
where IDL_DIR is the directory where you have installed IDL.
javaidlb.jar in the compile statement. This automatically accesses the connector object, java_IDL_connect, which is contained within the file. Enter the following two commands (as single lines) to compile and execute the program, replacing IDL_DIR with the IDL installation directory: javac -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" arrays_example.java java -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" arrays_example
| Tip See Note on Running the Java Examples for information on executing Java commands on a non-Windows platform. |
After compiling and running the project, the result of the array manipulation is printed to the command window, a subset of which appears in the following figure.
IDL Online Help (March 06, 2007)