Good day, I am trying to get a third party DLL to work in java (FWIW, I am using Netbeans 7.0). I am aware that getting third party DLLS to work (especially if it's not a C/C++ type DLL), is not an easy feat, and that you should use JNI to accomplish this. Like you guys know, following the JNI path will result in a wrapper for your DLL, which is exactly what I need. I will provide my code for both the C++ section as well as the Java section, and then the error message I receive will follow that. Please do note: I used javah to create the header file (see below) for the java file below. TestVC_OmniIDE
#include <windows.h>;
#include <stdio.h>;
#include "TestProgram.h"
#pragma once
using namespace System;
namespace TestVC_OmniIDE {
BOOL WINAPI TestVC\_OmniIDEMain(HANDLE hHandle, DWORD dwReason, LPVOID lpReserved)
{
return TRUE;
}
JNIEXPORT void JNICALL Java\_TestProgram\_UpdateTextFile(JNIEnv \*, jclass)
{
printf("Hello world from VC++ DLL");
}
}
TestProgram.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class TestProgram */
#ifndef _Included_TestProgram
#define _Included_TestProgram
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: TestProgram
* Method: UpdateTextFile
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_TestProgram_UpdateTextFile
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif
TestProgram.java
class TestProgram
{
public static native void UpdateTextFile();
public static void main(String args[])
{
System.out.println("Hallo from main");
}
}
Java Code to Call JNI Wrapper
public class OmniText {
static
{
System.loadLibrary("TestVC_OmniIDE");
}
public native void UpdateTextFile();
}
Here is where I call the native method
OmniText omni = new OmniText();
omni.UpdateTextFile();
As you can see, this is only a test, but as soon as this will be successful, I will create a production version taking parameters and returning a value. I know that the wrapper can be found, because, if I change the name of the wrapper file, it tells me that the file cannot be found. Now for the error (which can be identified from the post subject):
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkErro