I am developing a Java application but I am getting a java.lang.NoClassDefFoundError. I have checked everything I can think of:
- The jar file exists in the directory and is not 0 bytes
- The jar file has the same permissions as all other jar files (I have shown this with ls -la cmmand)
- The jar file contains the exact class that is reported as missing (I have shown this in output with the jar tf command)
- jar file is specified in the command string under the -cp option I have changed the order of jars in class path and the other
- jar files are recognised - otherwise the other parts of the program wouldn't work
- It is the same jar file I am building against
- Project works in eclipse on my laptop
It just doesn't work in my RaspberryPi.
I have to add something else to my checklist debugging of ClassNotFound errors. Does anyone have any suggestions?
I have the listing of the output of the checks I have run below.
pi@pi-raspbian-main ~/personal_services $ java -cp /home/pi/personal_services/Console/Console.jar:/home/pi/personal_services/lib/Library.jar:/home/pi/personal_services/lib/JavaCommon.jar:/home/pi/personal_services/lib/sqlite-jdbc-3.7.2.jar:/home/pi/personal_services/lib/commons-codec-1.10.jar metcarob.com.personalservices.console.Main /home/pi/personal_services/Console/ConsoleSettings.xml ListNodes
EVALUATING ListNodes
CONNECTING
Exception in thread "ConnectionThread" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at metcarob.com.common.network.xmlprotocol.ConnectionSocketContainer.ProcessIncommingMessages(Unknown Source)
at metcarob.com.common.network.xmlprotocol.Connection.processIncomingMessages(Unknown Source)
at metcarob.com.common.network.xmlprotocol.Connection.runDER(Unknown Source)
at metcarob.com.common.thread.CloseableThread.run(Unknown Source)
RUNNING ListNodes
Closing connection
Closing connection
DONE
pi@pi-raspbian-main ~/personal_services $ jar tf /home/pi/personal_services/lib/commons-codec-1.10.jar | grep Base64
org/apache/commons/codec/binary/Base64.class
org/apache/commons/codec/binary/Base64InputStream.class
org/apache/commons/codec/binary/Base64OutputStream.class
pi@pi-raspbian-main ~/personal_services $ ls -la /home/pi/personal_services/lib/commons-codec-1.10.jar
-rw-r--r-- 1 pi pi 284184 Apr 3 20:54 /home/pi/personal_services/lib/commons-codec-1.10.jar
Thanks Robert