Click here to Skip to main content
15,936,362 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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

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.

If you do not have the dll in the default directory then you should add the full path to your System.loadLibrary() call.
Share this answer
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.......
Share this answer
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
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900