Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java. lang. UnsatisfiedLinkError

 
karolos ignatiadis
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have the following problem:

When I execute "java main" a window pops up with the following error:

Microsoft Visual C++ Debug Library

Debug Assertion Failed!

Program: c:\j2sdk1.4.2_09\bin\java.exe
File: app3ds.cpp
Line:32 ASSERT(!afxContextIsDLL); // Should only be called by apps

If I press "Ignore" I then get a "java.lang.UnsatisfiedLinkError: D:\...\Hmi_HITDlg.dll: A
dynamic link library (DLL) initialization routine failed."

If I press "Retry" I get a java.lang.UnsatisfiedLinkError: D:\..Hmi_HITDlg.dll: One or more
arguments are invalid.

What I am actually trying to do is call a C++ function from Java using JNI (JNI code is generated using SWIG).

Here is my C++ function (in HMI_HITDlg.cpp):

-------------------------------------
float get_LongVel() {
return myInput.Vehicle.LongVel;
}
-------------------------------------

This is my JNI code (in HMI_HITDlg_wrap.cxx)

----------------------------------------------
JNIEXPORT jfloat JNICALL Java_Hmi_1HITDlgJNI_get_1LongVel(JNIEnv *jenv, jclass jcls) {
jfloat jresult = 0 ;
float result;

(void)jenv;
(void)jcls;
result = (float)get_LongVel();

jresult = (jfloat)result;
return jresult;
}
-----------------------------------------------

This is the code where I am loading the dynamic link library Hmi_HITDlg.dll (contains HMI_HITDlg.cpp and HMI_HITDlg_wrap.cxx
and other necessary files and is made using Visual C++ 6.0, from File->New->Projects->Win32 Dynamic-Link Library) in main.java:

-------------------------------------------------

System.loadLibrary("Hmi_HITDlg");


The size of the DLL that I am loading is approx. 2.04MB .

What is going on here? Please help!!
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like your JDK install (or one of the libraries it uses) is corrupted - I'd try to delete and re-install and see if it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic