I'm getting a NoClassDefFoundError exception with my project that uses the jacob library. I first encountered this problem when using a java byte code obfuscator on my project. The problem doesn't appear to be resulting from the obfuscation itself, but from a feature of the obfuscator which combines all of my projects jar files into a single jar (and this is a feature that I really would like to use).
My project runs fine if I use the files that come straight out of the NetBeans "dist" directory. This dist directory contains a "lib" subdirectory which contains jacob.jar. Now if I use the jar command to extract the "com" directory from jacob.jar and put it in the main jar and remove it from the lib directory it fails to run. I get the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread
The line of code that raises the exception is just calling on ComThread.InitMTA() and doing nothing else.
Does anyone know why it might be failing if I move the class files into another jar file? Perhaps there's something in the META-INF directory that also needs to be moved. If anyone has any ideas on this please let me know. I'm happy to provide more detailed information if necessary. Thanks.
-Jeff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Ihave the same eroor Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread.
What is the real solution? think you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm getting a NoClassDefFoundError exception with my project that uses the jacob library. I first encountered this problem when using a java byte code obfuscator on my project. The problem doesn't appear to be resulting from the obfuscation itself, but from a feature of the obfuscator which combines all of my projects jar files into a single jar (and this is a feature that I really would like to use).
My project runs fine if I use the files that come straight out of the NetBeans "dist" directory. This dist directory contains a "lib" subdirectory which contains jacob.jar. Now if I use the jar command to extract the "com" directory from jacob.jar and put it in the main jar and remove it from the lib directory it fails to run. I get the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread
The line of code that raises the exception is just calling on ComThread.InitMTA() and doing nothing else.
Does anyone know why it might be failing if I move the class files into another jar file? Perhaps there's something in the META-INF directory that also needs to be moved. If anyone has any ideas on this please let me know. I'm happy to provide more detailed information if necessary. Thanks.
-Jeff
How about /META-INF/JacobVersion.properties file? Shouldn't you copy it to your new jar file too?
Another question is: is java able to find dlls when jacob is moved to a different place?
You were right about JacobVersion.properties. Copying that file to the main jar fixed the problem. Many thanks.
Hi,
Ihave the same eroor Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread.
What is the real solution? think you