Bridges > Java Import Bridge > Showing IDL-Java Output In IDL

# Showing IDL-Java Output In IDL

By default, IDL prints the output from Java (the System.out and System.err output streams).

For example, given the following Java code:

public class helloWorld

{

// ctor

public helloWorld()

{

System.out.println("helloWorld ctor");

}

public void sayHello()

{

System.out.println("Hello! (from the helloWorld object)");

}

}

The following output occurs in IDL:

IDL> oJHello = OBJ_NEW('IDLjavaObject$HelloWorld', 'helloWorld')

% helloWorld ctor

IDL> oJHello -> SayHello

% Hello! (from the helloWorld object) IDL> OBJ_DESTROY, oJHello

Note: This example code is also provided in the helloJava.java and hellojava2.pro files, which are in the resource/bridges/import/java/examples directory of the IDL distribution. Run these example procedures by entering helloJava and hellojava2 at the IDL command prompt or view the files in an IDL Editor window by entering .EDIT helloJava.pro and .EDIT hellojava2.pro.

Note: Due to restrictions in IDL concerning receiving standard output from non-main threads, the bridge will only send System.out and System.err information to IDL from the main thread. Other threads’ output will be ignored.

Note: A print() in Java will not have a carriage return at the end of the line (as opposed to println(), which does). However, when outputting to Java both print() and println() will print to IDL followed by a carriage return. You can change this result by having the Java-side application buffer its data up into the lines you wish to see on the IDL-side.