I’m working with a commercial API Library that I do not have a license to distribute.
The end user of my application must have the library installed and in the classpath in order for my application to work. Beyond the jar, they must also have some other files in the LD_LIBRARY_PATH.
I’d prefer to run a test on start up that the pre-requisites are installed and the objects I’m using work properly. If not, return a user friendly message with instructions or perform some sort of correction. (like asking the user where the libraries are installed and writing some variables into the startup script).
I have found ClassLoader.loadClass and I think I should be using this, but I haven’t been able to find an example that spells out my use case and I’m not sure if it’s OK to use that directly.
I believe that if loadClass succeeds, I need to instantiate a class object and try using it to determine if the LD_LIBRARY_PATH is set correctly.
I’d appreciate any help.
You need a method that throws an Exception, inside that you can catch
ClassNotFoundExceptionorNoClassDefFoundErrorAddidional Info at NoClassDefFoundError