My Application Unable to Load dll no Exception Thrown.

Hi All, i am usingSystem.loadLibrary("cygProcessControllerNative"); to load the dll library.But it simply not moving out of this line,and there is no exception thrown.pls help me.Cheers:Akash
[219 byte] By [Akash5495a] at [2007-11-27 0:19:16]
# 1
Are you sure your dll works fine? Are you able to load dll from, say, C code?
Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Thx for reply Michael,my C code is also loading WINAPI aspi.dll.I have put print statement before and after load Library .so i am sure control is reaching just before the statement.but not printing after.So just want to know why its taking so long to Load the library.and as i have told earlier no exceptions.

Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
No, my question was "are you able to load problematic dll" not some winapi dll.
Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

No its just hanging at the loadLibrary statement.

try{

System.out.println("Before Loading-->");

System.loadLibrary ("cygProcessControllerNative.dll");//Hanging here

System.out.println("In After Loading Lib--

}catch (java.lang.UnsatisfiedLinkError e)

{

System.out.println ("Exception in ProcessControllerNative.class"+e);

}

First print statement is getting Printed.

Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5

Well, you should not use extension in this call

System.loadLibrary ("cygProcessControllerNative.dll");//Hanging here

should be

System.loadLibrary ("cygProcessControllerNative");//Hanging here

But my question was - are you sure your DLL is workable and not corrupted? Can you load your cygProcessControllerNative dll not from Java but from other C application for example?

Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6
I haven't tested it in Other Programming language but Other java application is also behaving same which was loading other dll's but not this one.
Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 7
Did you try to remove ".dll" from call?
Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 8
yes,but the problem is same.My application contain just one .c file and i am using netbeans IDE.its compiling correctly.
Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 9
BTW how did you compile c file using NetBeans? :)
Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 10
C/C++ Pack is there.its using JNU Ccompiler.
Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 11
Never work with this pack unfortunately.Anyway you need to check you dll - was it compiled correct way or no. Try to create simple C code to load your dll and check.
Michael.Nazarov@sun.coma at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 12
Thx for your reply.i will try .
Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 13

If the dll load line is "hanging" then the problem is in the library and it has nothing to do with java nor even with JNI.

Windows dlls have a method calls something like DLLMain() which gets called when a dll is loaded. That is an OS operation not a java one.

If that never returns then the dll will never finish loading.

If your dll references other dlls then the samething can occur with those other dlls (the main method never returns.)

Repeating it again....none of this has anything to do with java nor JNI.

jschella at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 14

Thx for sharing the knowkedge,but not sure how to make problem free dll.i have structure like this....

1.java file containing main method and loading lib.

2.java file containing native method decleration.

3.java file containing filelds.

4.c file implementing native methods.

can you tell me steps,how to make it work.

Akash5495a at 2007-7-11 22:10:41 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 15

> Thx for sharing the knowkedge,but not sure how to

> make problem free dll.i have structure like

> this....

> 1.java file containing main method and loading lib.

> 2.java file containing native method decleration.

> 3.java file containing filelds.

> 4.c file implementing native methods.

>

> can you tell me steps,how to make it work.

Make what work?

If you can't load the library then you can't do anything in java.

If you can't load the library then it has nothing to do with java nor JNI.

And I already pointed out the most likely reason for it hanging. Or perhaps the only reason (a load error would produce an exception.)

jschella at 2007-7-21 19:42:44 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 16
Tyy this from command prompt and see what error is thrown.cd to your dll location and typeregsvr32 <dllname.dll>
kteegalaa at 2007-7-21 19:42:44 > top of Java-index,Java HotSpot Virtual Machine,Specifications...