How to write a JNI dll bridge

i have a dll driver to use in my Java application. I read that i need to create a dll bridge for JNI. First of all I would like to know if exists some utility to creare automatically this bridge.

I have the source code of the Dll, and I also know how to creare my bridge header file (javah) but I can not understand how to put into bridge implementation because i just need to call the driver method.... Can you help me?

For example this is the header of my driver:

int  CALLINGCONV Initialize(int Slot);
int  CALLINGCONV Finalize();
int  CALLINGCONV FinalizeML(int nSlot);

I also read about JNA, it seems easier but maybe it not very fast, is it true? Thnak you


JavaCPP is as easy as JNA, but as fast as raw JNI. For example, this Java class could let access efficiently those four functions in Java, assuming the header and library files are named "Driver.h" and "Driver.lib" respectively:

import com.googlecode.javacpp.*;
import com.googlecode.javacpp.annotation.*;

public class Driver {
    static { Loader.load(); }
    public static native @Cast("BOOL") boolean IsInitialized();
    public static native int Initialize(int Slot);
    public static native int Finalize();
    public static native int FinalizeML(int nSlot);

I can suggest you 2 different libraries that make easier work with JNI

Need Your Help

Can an ASP.NET 5 web application published in windows be run on linux?

visual-studio-2015 visual-studio-code dnx kestrel-http-server

I have a sample ASP.NET 5 web application created in Visual Studio 2015 using the default web application template.

How to stop Google Play Games window from popping up if there is no INTERNET

google-drive-sdk in-app-purchase in-app-billing google-play-games google-api-client

I use the Plus.API, Game.API, and Drive.API for IN-APP Purchases, LeaderBoards, and Saving game settings respectively.