Java - Trouble Shooting
Last Updated: 2021-11-19
NoSuchMethodError vs ClassNotFoundException
Both are commonly seen at runtime, telling you something is missing, but the fixes are different:
- cause: the version used to build is different from the one used to run. The internal interfaces may change from the version to version, the "Method" may be available in compile time but not in run time.
- fix: make sure you are using EXACTLY the same versions in both environment.
- cause: some jar is missing in classpath
- fix: add the jar to classpath(e.g.
java -cp <classpath>)
Got the error message when using Mac OS X + Java 7
java.net.UnknownHostException: ComputerName: ComputerName: nodename nor servname provided, or not known
/usr/bin/ld: cannot find -ljava
Problem: Libraries are missing.
libjava.so is missing. Check
In my case: Install 64-bit jdk to a 32-bit machine.
Solution: Install the missing libraries