• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ActiveX call from JNI

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All ,
I have been trying to find a solution for loading an ActiveX component dll thru JNI and executing one of its functions.
I have created a dll and wrote a simple funtion in it.
Using System.load() method i loaded the same dll in da memory.
But i am not able to make any native calls .
Please could anyone suggest me any alternative to this.
Please find the code pasted below.


Program Output :

Loaded !!
Exception in thread "main" java.lang.UnsatisfiedLinkError: printMessage
at scjp.TestNullVector.printMessage(Native Method)
at scjp.TestNullVector.main(TestNullVector.java:23)


Can someone throw some light on the same ..
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UnsatisfiedLinkError means the DLL cannot be found.
You are passing the complete path to the DLL in your System.load() call. This is incorrect. One only passes the name of the library.
The path to the library must be set in the OS environment (PATH in Windows, LD_LIBRARY_PATH in Linux).
Have a look at the example in the Java Tutorial for more on correctly using JNI.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't the fact it didn't throw when doing load() mean that it DID find the DLL? Is the problem not in fact the use of load() not loadLibrary(). As I understand it, load() just loads the DLL into memory. If you want it to automatically link the DLL to native methods, you need loadLibrary(), I think.

By the way, what's this "in da memory" about? Please use real words (see JavaRanch guidelines).
[ March 26, 2007: Message edited by: Peter Chase ]
 
Mahendra Shelke
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for those slang Peter ..
I got the answer , thanks a lot guys for your help ..


public class JNITest
{
static
{
System.loadLibrary("JNITest");
}

native void showMessage(String str);

public JNITest()
{
System.out.println("In the constructor of the java program");
}

public static void main(String s[])
{
JNITest JNT = new JNITest();
JNT.showMessage("Passing string from Java");
}
}


 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic