• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DLL's, dynamic linked library

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've made a game using Java in Eclipse that is supposed to use a coin dispenser as an automatic reward system. The coin dispenser came with 3 DLL's, but I can't get it to load the DLL's. This is the class I've created to load the DLL's, "CoinDispenserInterface.java":

package SubSearch;
/*import C:/Windows/System32/Coinco.MDB.dll;
import CoinDispenserInterface.dll;
import cai_mdb_w32d.dll;//*/

class CoinDispenserInterface
{

public native void inDll();

public static void main(String[] args)
{
System.out.println ("dispensing coin in interface");
//new CoinDispenserInterface().dispenseCoin();
}

static
{
System.out.println ("Loading DLLs");

System.loadLibrary("C://WINDOWS//system32//cai_mdb_w32d.dll");

System.loadLibrary("C://Documents and Settings//Devin//My Documents//Dropbox//" +
"PsychologyDept//workspace//SubSearch//DLLs//Coinco.MDB.dll");
System.loadLibrary("C://Documents and Settings//Devin//My Documents//Dropbox//" +
"PsychologyDept//workspace//SubSearch//DLLs//CoinDispenserInterface.dll");

System.out.println ("Loading complete");
}
}


When I use System.loadLibrary I get a java.lang.UnsatisfiedLinkError that says the cai_mdb_w32d.dll isn't in the java.library.path, which doesn't make sense b/c when I click on configure build path, it's listed there.

When I use System.load I get the same error with a different explanation: "This application has failed to start because the application configuration is incorrect." It suggests reinstalling the application.

I've tried storing the 3 DLL's in the C:/WINDOWS/System32 folder, but it didn't seem to help. Even if I were to get this to work, I don't understand how this class's main() is supposed to work with the main() my game already has.

Any help is greatly appreciated.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, first of all you don't import them into your source code. So "import X.dll" is not what you do (it doesn't do anything).

And second of all the API documentation for the loadLibrary() method says

Loads the dynamic library with the specified library name. A file containing native code is loaded from the local file system from a place where library files are conventionally obtained. The details of this process are implementation-dependent. The mapping from a library name to a specific filename is done in a system-specific manner.



In other words you don't pass a path to that method. You pass just the name of the library and put the actual DLL in the right place. As the error message says, that's the "java.library.path" which you appear to have assumed is the same as the build path of your Eclipse project. (Hint: bad assumption. Check the value of the system property by that name.)

(Also this isn't a question about Servlets so I'm going to move it.)
 
Devin Crane
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tips. They helped. The biggest thing I'd have never guessed was not including the path to it, or the '.dll' extension.

One more question, at least for now: running System.loadLibrary("cai_mdb_w32d"); produces the error now that 'This application has failed to start because the application configuration is incorrect.' I'm still researching what this means and how to fix it, but is anyone familiar with this error? Is it something I can fix or can only the company that provided me with the dll address the issue?

Thanks!
Devin
 
reply
    Bookmark Topic Watch Topic
  • New Topic