Compiling the IDL with Java

Oddly enough, the Java IDL compiler is not distributed with JDK 1.2, the first Java release to provide a CORBA compliant ORB. I imagine this will change in future releases. You may download the Java IDL compiler from the Java Developer Connection (JDC); they require you to register with them, but it's free and relatively painless. There is good documentation and examples of JavaIDL there as well.

I used the Windows version of both the JDK 1.2 and the Java IDL compiler. Of course, given Java's platform independence, that shouldn't matter to you. Use whichever JDK 1.2 development environment you prefer.

As with the TAO IDL compiler, we use the Java IDL compiler, idltojava.exe, to generate the stub and skeleton classes necessary for our Java client and server, respectively. Assuming idltojava.exe resides in our PATH, we can do something like this:

	> idltojava Hello.idl 
Unlike tao_idl, idltojava.exe may not create the same number of source files for every IDL file it compiles. This is due to Java's file naming convention: for any class, SomeClass, it must be contained in a file named SomeClass.java. So the number of files generated by idltojava depends on the number of interfaces and datatypes defined in the IDL file. And remember how IDL modules map to C++ namespaces? (Did I mention that?) Well, in Java, an IDL module corresponds to a Java package, and since Java packages are represented as directories on your disk, the Java IDL compiler will create a directory for each module declared in the IDL file. Our World interface isn't defined within a module, so the following files are created in the current directory:

Let's move on and write a Java server.

Back to... [ Corba Tutorials ]


Jim Crossley
Last modified: Thu Mar 25 15:50:15 EST 1999