UnsatisfiedLinkError in Jbuilder 8, but not when outside!

Posted on 2004-03-26
Medium Priority
Last Modified: 2010-05-18
I'm trying to access a dll file via JNI. When I run the standard DOS prompt and arguments, it runs fine, returning the results I need.

I then adapt part of the Java code to input it into a project in Jbuilder 8, and I plac the dll file in the PATH, so i can be seen. However, when I try to access the dll during runtime, Jbuilder returns an java.lang.UnsatisfiedLinkError.

I have tried many things, placing the same file in multiple paths that appear in the PATH variable, in the place the class files reside, and I've tried changing the properties of the project itself to allow certain paths to be included in the search. All to no avail.

From what my tests have proven, the problem lies within Jbuilder 8, not Java or my inability to refer to it via the PATH variable. I've done some reading and edited the jdk.config file, using the:

vmparam -Djava.library.path=c:\windows\system32

But still it doesn't want to find the dll. Anything else I'm missing?
Question by:MorsVitaEst
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5

Expert Comment

ID: 10697352
If I understand correctly, you shouldn't edit any config files that come with JBuilder8, what you should do is edit the "Project Properties" for the current project and add the runtime configuration to include your special params.

Author Comment

ID: 10699623
I've tried that, using many different variations. One main difference I made to the code to access the dll is this, it was accessed directly in a short main method, and then the method would quit. I changed it to no main method, except the one I use in my larger program. After creating a test class to access the one that loads the dll, in the DOS window, it works fine.

JBuilder is the problem, I've recompiled the dll many times, each time working in the original version, and then not working in the main project file. I've added all the paths even in area you suggested, but nothing, just more java.lang.UnsatisfiedLinkError.

What's strange is that it can obviously find the file in the PATH, as it would leave a custom error message if it couldn't find it, yet it chooses not to load the necessary method from within the dll.

The only other explanation is the introduction of package names, as my project has different package names to that of the smaller project (with the short Main class). However, there is simply an extension of them (let's say it was google.api.com, then I added another two extensions, string.find.google.api.com). Could this be the problem?

An expert on the intricacies of JBuilder would be appreciated.

Expert Comment

ID: 10700229
Working with DLL's as far as I remember is pretty simple, defining the native method, loading the library and that's about that.  Package names as far as I know don't even get into this.  JBuilder shouldn't be interfering with anything as far as I know if the DLL is located with all the other classes (respective to the package names).

Does the code that JBuilder compiles actually work from a DOS prompt window, or do you also have to compile the java code using javac with the regular JDK for things to work?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 10700788
Well, everything compiles fine in JBuilder, and the problem only occurs during runtime, when the dll is accessed. I can't run it in a DOS windows since I can't actually figure out how to do that :) I've tried with a custom .bat script to run the java -classpath etc in one go, but it doesn't work properly, since I'm assuming that JBuilder has a lot of custom variables put into that. This would probably be the key to making it work, if I can find a method to run my files outside of JBuilder. The problem is catching all the several directories that the files lie in. I currently have three lcoations for files.

The home directory:
... jbproject\untitled1\classes

Then the classes reside in the following directories.


The Main method lies in spellchecker\frontend\OpenDocument.class

The files are also all labelled in packages, spellchecker.backend, spellchecker.backend.edu.princeton.wordnet, and spellchecker.frontend. The bat file I have to run it is:


set MYCLASSES=spellchecker/frontend;spellchecker/backend;spellchecker/backend/edu/princeton/wordnet
set MYNATIVELIB=c:\wnjn\java\CUSTOM\jar

call "%MYJAVA%\java" -classpath "%MYCLASSES%" -Djava.library.path="%MYNATIVELIB%" spellchecker.frontend.OpenDocument


The error I get is:

Exception in thread "main" java.lang.NoClassDefFoundError: spellchecker/frontend/OpenDocument

I'm guessing more needs to be done to make it run properly.

Expert Comment

ID: 10706439
>> set MYNATIVELIB=c:\wnjn\java\CUSTOM\jar

Is c:\wnjn\java\CUSTOM\jar the location where your DLL file exists?

>> Exception in thread "main" java.lang.NoClassDefFoundError: spellchecker/frontend/OpenDocument

This means one of the classes wasn't found/resolved properly, is spellchecker.frontend.OpenDocument the class that accesses the DLL and therefor can't be resolved, or is it missing entirely?

>> ...since I'm assuming that JBuilder has a lot of custom variables put into that...

As far as I remember, JBuilder doesn't add anything to the JVM params unless you're debugging your app, or you've specified the params yourself.

>> ...if I can find a method to run my files outside of JBuilder...

>> set MYCLASSES=spellchecker/frontend;spellchecker/backend;spellchecker/backend/edu/princeton/wordnet

This is wrong, it should be:

set MYCLASSES=jbproject\untitled1\classes

because Java takes the package name and automatically converts it to the correct path to find each and every class!

Hope this helps,

Author Comment

ID: 10709460
Thanks, that helped a lot, so now it manages to run, but once again, only up until the point where the dll is accessed (which is when I click a particular button in the GUI). The same error message appears once more.

And yes, MYNATIVELIB is where the dll is located, I chose a different area in case it couldn't read the default system32 one.

Still supremely puzzled over why it won't find it... It works with the other, smaller version that doesn't include all the different classes and packages...

Expert Comment

ID: 10710317
Again, if I remember correctly, IF there is some problem with the declaration of the native method in the Java files as opposed to the actual method signature in the DLL, that is expressed by the UnsatisfiedLinkException...

Author Comment

ID: 10793898
Ok, I've sorted the problem, despite creating package names for the other smaller program, and the same file being read, it didn't work in JBuilder 8. So I tried a different tack, after reading here:


I realised that this might be the problem. Slight as it may be, without any knowledge of C, I edited the native Java method in the C code, and added the package names for my program in the methods, and recompiled the entire thing. The smaller program didn't work, but then I tried in my large program, and it worked perfectly!

Turns out that JBuilder 8 needs the precise package names in the methods to read the from the dll file.

I'll give you 100 points for helping me, and the .bat file commands which are useful when I plan to run it quickly without JBuilder popping up. Thanks again.

Expert Comment

ID: 10795109
No objections :)

Accepted Solution

Netminder earned 0 total points
ID: 10820602
Closed, 500 points refunded.

doronb: there is a "points for" question for you at http://www.experts-exchange.com/Q_20949831.html

Site Admin

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question