Is there an easy way to call C++ code from Java and the other way around?

Alexander Krapf

The JunC++ion tool by Codemesh (http://www.codemesh.com) does just that.

JunC++ion has a code generator that generates C++ proxy classes for Java classes. These C++ proxy classes are usable like the underlying Java classes. All communications between components in the two different languages are performed under the hood through JNI.

This allows you to write C++ code like:

  #include "java_lang_System.h"
  #include "java_lang_String.h"

  using namespace java::lang;

  int main()
    String         test( "test" );

    System::out.println( "This is a " + test );
The code generator is capable of generating C++ proxy classes of all compiled Java classes. Therefore you can use it to
  • call EJB servers from C++ clients
  • put Swing GUIs on C++ applications
  • port your C++ applications to Java in small increments
  • provide a C++ API for your Java library and reverse
  • etc.
JunC++ion is currently generally available on "Wintel" where it works with all major JVMs (Sun, IBM, and Microsoft). Ports to Solaris, AIX, Linux and HP-UX are underway.