6.3. Call a C/C++ Program from Java

In this section, we want to develop a more complicated and more practical example to illustrate more functionalities of the interface between Java and a native language — here C/C++. The example program we develop generates and calculates a random sequence in two different domains. A random sequence is created in the Java domain by using Random class, which is located in the java.util class library. This random sequence is passed to a native method developed in the Visual C++ domain as an array argument, and the latter will calculate the maximum, minimum, and mean values for that random sequence. The calculated results will be returned to the Java domain in an array format, too.

A GUI will be developed in the ...

Get Applications Interface Programming Using Multiple Languages: A Windows® Programmer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.