I have an application in Eclipse that runs fine in Eclipse. I have been testing it as a jar file for some time, but today I got the error java.lang.NoClassDefFoundError. After browsing the Internet I have found many discussions but no solution; I have also read answers to similar questions in this forum. Please tell me what do I have to look inside the jar file or what log do I have to look into.
Your help will be greatly appreciated,
Alejandro Barrero
Further clarification. The error I receive when executing a batch file with contents "java -jar paperless.jar" is "java.lang.NoClassDefFoundError: org/objenesis/Objenesis"; however, after I unzipped the jar file the file ".classpath" contains:
After unzipping objenesis-2.6.jar I found out that the class is there.
Your help will be greatly appreciated,
Alejandro Barrero
.classpath only works inside Eclipse. When you run your JAR outside of it the file has no meaning at all. Instead you should use META-INF/MANIFEST.MF to add a Class-Path entry: https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html. Note that these dependencies cannot be located inside your JAR file, because the class loader won't be able to find them there. The best is to use a relative path, and ship the JARs with your own JAR inside a ZIP file. Make sure that you are allowed to though, some libraries may prohibit this.
Thank you for your prompt reply. I have no intention of using the classpath; I only posted what is in the jar file. The jar file is created by Eclipse and until yesterday it was working fine. If worse comes to worse, I am willing to modify the jar file, but someone has to tell me how.
Your help will be greatly appreciated,
Alejandro Barrero
1. How you run the jar file, using command prompt or using IDE 2. If run thru command prompt, can you whats the classpath variable points to.
3. For which class it is throwing NoClassDefFoundError.
Alejandro Barrero wrote:
As I mentioned in a previous response, org/objenesis/Objenesis class shows in the jar file after I unzipped it.
Your previous response mentioned that you unzipped a different jar file ... and Rob mentioned that you need to modify the manifest to point to that different jar file. Are you now saying that the class exists in the paperless jar file that is executed?