• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI UnsatisfiedLinkError only thrown once  RSS feed

 
rob harvey
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I have a try catch round my native method call to catch an UnsatisfiedLinkError if the library has not been put on the users path. To test this I leave the library off the path and the first attempt to call the method throws an unsatisfiedlinkerror - but when i try again (the method call is caused by swing button click) the exception is not thrown and the method never returns? any ideas?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an exception occurs while initializing a class, the ClassLoader isn't going to try to load the same class file again.
 
Stephen More
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this situation, can you force the classloader to try again ?

I have tried the following without much success:

try
{
the.native.method()
}
catch( java.lang.UnsatisfiedLinkError e )
{
dll = download from web and put it in the path
java.lang.ClassLoader cl = Thread.currentThread().getContextClassLoader();
cl.loadClass( "the.native" );
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!