cancel
Showing results for 
Search instead for 
Did you mean: 

Native methods(C/C++) in Java classes

Former Member
0 Kudos

Hi, All!

Can I invoke functions from DLL (C++ functions) in Java classes? I have to call the function in the class related in a portal archive (PAR file).

Thanks in advance,

Swapna.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Writing native methods for Java programs is a multi-step process.

Begin by writing the Java program. Create a Java class that declares the native method; this class contains the declaration or signature for the native method. It also includes a main method which calls the native method.

Compile the Java class that declares the native method and the main method.

Generate a header file for the native method using javah with the native interface flag -jni. Once you've generated the header file you have the formal signature for your native method.

Write the implementation of the native method in the programming language of your choice, such as C or C++.

Compile the header and implementation files into a shared library file.

Run the Java program.

Former Member
0 Kudos

i think you have answered your own question.