Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Invoking dll methods from Java

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a dll with few methods I'd like to call. Problem is I don't have any API for it.
I'm using Dll Export Viewer to see what functions are available.
Most of the functions have signature like this:

There is one which is just called:

I'm using JNA to load and invoke dll methods. When I invoke the testMethod it works just fine, so I assume that the dll lib is loaded properly. Problem is with other methods. I can't call them using full "_Java_something_MethodName" or just "MethodName". Is it a diffrent type of method, is it somewhere else not in the loaded dll, is there diffrent way to invoke such method?

The Exception thrown when trying to invoke those methods is:
Posts: 21972
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure these functions* start with _Java, and not Java? Because they look like JNI functions. If you create a native method in Java, then use javah to create a header, that header includes a lot of functions in the following format: Java_<full class name with . replaced by _>_<method name>. For example, if your class is com.coderanch.test.MyClass and it has a native method runTest, then function Java_com_coderanch_test_MyClass_runTest will be created.

That said, these JNI functions shouldn't be called directly but through their native methods in Java. It's a wonder you even managed to properly create the required JNIEnv and jobject / jclass values required to call these JNI functions.
Grzegorz Novvak
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a newbe to native methods so I don't understand few things. The whole aplication which contains mentioned dll file is a Java Applet. This applet contains a dll file. The applet class contains simple methods like init, some checks and native methods FindSomething, GetSomething and others. Are those the methods which I see in Dll Export View as _Java_something_FindSomething@8 etc? Or are those methods placed somewhere else?

Is there a way to invoke them through the applet?
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic