"JunC++ion is our JNI Expert"


This software development group was handed a problem they had no part in making: their company had acquired a start-up company for a product that will provide complementary functions to their company's product set, including a strong web interface. The web interface was good news, now they wouldn’t have to develop their own. The bad news was that the web interface was in Java, but the data it had to access was in a database with tried-and-true access and retrieval mechanisms coded in a C++ library. Several other company products used the same data and the same C++ library. The software development group had to figure out how to provide database access to all the company's products, include the new one, so that all products could continue accessing the database for years to come.


The software group had to get that web interface in Java talking to the C++ library so that it could access the database, and without touching the C++ library.

Detailed problem description

The database stores data used by several company products. Its schema is updated on a regular basis to add, remove, and change the database tables. Several products in the company use the C++ library, which is tightly coupled to the Windows platform, to access, retrieve, and update data in the database. The C++ library could not be changed. It is working well and it provides efficient access to data for many products, including products that are not updated frequently.

The company's new product is in Java and it provides a web-based solution that customers are demanding. It too must access the database but there is no corresponding Java interface to the database.

The software group must provide the Java product with access to the data in the database, using the C++ library without changing the C++ library at all.


There aren't many solutions for integrating Java and C++. This group was forced to consider the Java Native Interface (JNI) to provide Java to C++ interoperation. Because JNI is a low-level language, coding in it is very complicated and usually requires special JNI expertise. There were no JNI experts in the group and no JNI experts readily available within the company. The software group had to hire a JNI expert.

Then the group evaluated JunC++ion. Although JunC++ion uses JNI to integrate Java and C++, programmers never see the JNI or use it. After the evaluation, the project leader summarized the group's conclusion: "JunC++ion is our JNI expert". With JunC++ion, the C++ programmers use the generated C++ proxy classes to build the Java version of the database access library.

How JunC++ion is used

Although the programmers could have used the C++ proxies directly in the C++ library, they chose not to. By leaving the C++ library unchanged, the other products using it would be assured continued use without any modifications. A C++ proxy layer was created for the Java code to talk to and the proxy layer subsequently talks to the untouched C++ library.

Detailed solution description

1. Development:

The software development group uses a perl script to automatically generate the C++ library for accessing the database tables. The programmers updated the script to:

  • Generate a Java library, which includes classes with native methods
  • Generate C++ code, which implements the native methods. The native methods will call the C++ library for database access, on behalf of the Java client.

2. Use JunC++ion Code Generator:

The Java classes are imported in the JunC++ion Code Generator.

The Code Generator generates C++ proxy classes corresponding to the Java classes. About 1700 classes are currently generated.

3. Build and deploy JunC++ion enabled library. The figure below shows the final JunC++ion solution:

The Java libraryA, C++ proxy classesB, and C++ native method implementation codeC are built and deployed with the JunC++ion runtime library D. The Java client Fuses the JunC++ion enabled library E to talk to the C++ library G for accessing the database H.

The complete solution

Copyright 2006-2015 by Codemesh, Inc., ALL RIGHTS RESERVED

CISCO® Systems
home products support customers partners newsroom about us contact us