The following example creates a simple Java application that includes two text boxes. An IDL command typed in the top textbox is passed to the IDL process through using the executeString method. Command output and any error messages are printed in the bottom textbox.

Note: The file for this example, JIDLCommandLine.java, is located in the examples/doc/bridges/java subdirectory of the IDL distribution.

  1. Open the file named JIDLCommandLine.java in the location referenced above:
  2. Open the Windows Command window by selecting Start > Run and enter cmd in the textbox.
  3. Use the cd command to change to the directory containing the JIDLCommandLine.java file.
    For a default Windows installation, the command would be:
  4. cd IDL_DIR\examples\doc\bridges\java
    where IDL_DIR is the directory where you have installed IDL.
  5. Reference the classpath of 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:
  6. javac -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" JIDLCommandLine.java
    java -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" JIDLCommandLine

Note: See Note on Running the Java Examples for information on executing Java commands on a non-Windows platform.

After compiling and running the project, a simple command line interface appears as shown in the following figure.

Send commands to the IDL process by entering them in the top text box and pressing the Enter key. Any output or errors will appear in the lower text field.