Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java JNI
Hi, every body
 
i have developed a java class named A that uses another class named B , both of them is in package com.kkp ,
the class B have some native methods that implemented in B.cpp & B.h
i have used g++ for compiling the cpp file and creating a dll (B.dll).
til here every things is OK and program works fine .
i have create a jar file and the i put the B.dll, B.class and A.class in it,
 
the flow of jar (my library) is :
Class A be called form main application and then it calls class B methods and the native methods cause execution of B.dll functions (C++ dll) to support working on external hardware (some kind of printers).
 
the jar file also executes OK and no problem
the jar file manifest is
 
Main-Class: com/kkp/A
Name: com/kkp/
Sealed: true
 
but my problem is where another application load the jar file as library and wants to execute the functions in side class A , in this state a run-time error (UnSatisfiedLinkError) appears . i know that this error basically is because the class B count not find the B.dll in this code
System.loadLibrary("B");
 
i want to put my jar file in Lib folder of my application.
when i put the jar and B.dll in Lib folder the UnSatisfiedLinkError occurs in run-time but when i put the B.dll in root directory of application it works OK and no run-time error occurs.
 

my question is what i must do ?, i mean that the jar file must put in Lib folder but where the B.dll must be ? (i don't want to put the dll in root of application's directory)
 
i know this question is maybe so simple because i have a few experience in java programming
 
thanks in advance.
Posted 27-Dec-11 20:37pm
Areff781
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you do not have the dll in the default directory then you should add the full path to your System.loadLibrary() call.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

since u want to create a A.dll and call B.dll from A.dll, so i would recommend u to jst create the B.lib and put it inside A.dll then u will be able to call the functions of both class A&B
 
hope this will work........All the best.......
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

for the System.loadLibrary() call the dll file should be in path of java i.e system32 but i would recommend System.load() instead by which you would be able to give full path of the dll file and use it in any other java app usin that jar
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Maciej Los 285
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 186
4 Aajmot Sk 153
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100