Friday, May 2, 2014

Compiling and Executing a java native interface code

In order to create a java native interface we need to write a class which contains native functions. Suppose SystemCheck.java is the java file containing the native functions.
Keep SystemCheck.java in the package com/tp/pc/schedule/system

For compiling 
 javac com/tp/pc/schedule/system/System.java

This will create a class com/tp/pc/schedule/system/System.class

Create a header File for the class
javah -d inc com.torresnetworks.policycontrol.schedule.system.System

Execute 
java -Djava.library.path=/path/to/native/library -jar system.jar