I\'m getting an odd error when I try and run this program. The class compiles fine into multiple .class files and I compiled it last week (before editing it) just fine. But
This is indeed disallowed as per VM Spec 4.9.1:
The
class
file must not be truncated or have extra bytes at the end.
This can occur if there's an incompatibility in Java compiler and Java runtime used. Verify both versions and make sure that you compile for the right runtime versions. I.e. the compiled class can be used with same or newer runtime version, but not always with older runtime versions. Check the versions using java -version
and javac -version
.
Another common cause is that the file get corrupted during file transfer (FTP) between different machines. This transfer should be done in binary mode rather than text mode.
Another possible cause is a hardware error, e.g. corrupt harddisk/file/memory. Try recompiling or another machine.