This discussion is archived
2 Replies Latest reply: Jul 18, 2012 2:28 AM by rukbat RSS

link library for JNI

948966 Newbie
Currently Being Moderated
Hye all, Im want seek help from you guys....I use Dev-C++ as my platform to do c program and header file....i in progress to integrate this c program with java program....and now, im already link my c program with existing dll...where in c program i will called function in existing dll....for simply flow, its just like this:

java program will load c program where in c program contain existing dll that have many function inside it...then, i interested to call one of the function from the dll, named MMReader_Initialise....ok, its just overview only...

so now, i have problem when to compile all of this in cmd window....some said just use : CL -LD MMMReader_Initialise_L5.c MMMReaderHighLevelAPI.lib -FeMMMReader_Initialise_L5.dll...but it came with error like this :
Microsoft <R> 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
Copyright <c> Microsoft Corporation. All rights reserved.

MMMReader_Initialise_L5.c
MMMReader_Initialise_L5.c<1> : fatal error C1083: Cannot open include file: 'jni.h': No such file or directory

they said, Dev-C++ cannot support this command just only Microsoft Visual Studio..but I really want to know by using Dev-C++...can you guys help me....below is the reference for related code:

MMMReader_Initialise_L5.c :
#include <jni.h>
#include <stdio.h>
#include "TestMMMReaderHighLevelAPI5.h"
#include "MMMReaderHighLevelAPI.h"


JNIEXPORT void JNICALL 
 Java_TestMMMReaderHighLevelAPI5_MMMReader_1Initialise_1L5(JNIEnv *env, jobject obj)//Library "MMMReaderHighLevelAPI"
 {
            int hwnd;          
            hwnd = MMMReader_Initialise(null, null, null, null, false, false, null);
            return;                                                       
    
        
 };
TestMMMReaderHighLevelAPI5.java
public class TestMMMReaderHighLevelAPI5{
     static{
               System.out.println("inside static block");               
               try{
                    //System.loadLibrary("MMMReaderHighLevelAPI"); //can't find dependent library -mungkin ini bukan native
                            System.loadLibrary("MMMReader_Initialise_L5"); //no this file in java.library.path -ade masalah nk rebuild all     
                            System.out.println("Loaded MMMReaderHighLevelAPI DLL");
               }catch(UnsatisfiedLinkError e){
                    System.out.println("Couldn't load MMMReaderHighLevelAPI DLL");
                    System.out.println(e.getMessage());
               }
     }

     public static void main(String[] args){
          
          TestMMMReaderHighLevelAPI5 t = new TestMMMReaderHighLevelAPI5();
          try{
               t.MMMReader_Initialise_L5();
                        //t.MMMReader_Initialise_L();
               System.out.println("MMMReaderHighLevelAPI DLL method invoked!");
          }catch(UnsatisfiedLinkError e){
               System.out.println("Couldn't Access MMMReaderHighLevelAPI DLL method");
               System.out.println(e + "");
          }
            //new TestMMMReaderHighLevelAPI5().MMMReader_Initialise_L5();
     }
     
     
        public native void MMMReader_Initialise_L5();
        //public native long MMMReader_Initialise_L();
}
i want refresh back about this command, CL -LD MMMReader_Initialise_L5.c MMMReaderHighLevelAPI.lib -FeMMMReader_Initialise_L5.dll , u guys think, this -FeMMMReader_Initialise_L5.dll is dll for c program or dll for existing API...im not sure about this..thanks for spending ur time read my thread...

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points