Hello World Example with a Java Connector Object
To create a Java application that uses the connector object's executeString method to print "Hello World" in the command window, complete the following steps.
Example Code
The file for this example, hello_example.java, is located in the examples/doc/bridges/java subdirectory of the IDL distribution.
- Open the file named
hello_example.javain the location referenced above. - Open the Windows Command window by selecting Start → Run and enter
cmdin the textbox. - Use the
cdcommand to change to the directory containing thehello_example.javafile. For a default Windows installation, the command would be: - Reference the classpath of
javaidlb.jarin 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, replacingIDL_DIRwith the IDL installation directory:
javac -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" hello_example.java java -classpath ".;IDL_DIR\resource\bridges\export\java\javaidlb.jar" hello_exampleTip
See Note on Running the Java Examples for information on executing Java commands on a non-Windows platform.
After compiling and running the project, "Hello World!" will appear in the command window.
Note
An expanded "Hello World" example that allows you to optionally say hello from someone can be found in Hello World Java Example with Additional Method. This example uses a custom IDL object with a method and the Export Bridge Assistant to create the necessary wrapper object files.