java.lang.ClassFormatError: Extra bytes at end of class file

前端 未结 6 1571
鱼传尺愫
鱼传尺愫 2021-01-04 11:23

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

6条回答
  •  有刺的猬
    2021-01-04 12:01

    To clarify: this happens after you've cleaned out all old .class files and recompiled on the same machine?

    Or are you compiling on one machine and then copying the files to another? If that's the case, then it's likely that your file transfer software is corrupting the files (Windows <-> Linux is a common culprit, most often by adding/removing a 0x0D byte, but occasionally by adding a 0x1A DOS EOF marker).

    I suspect that if you check your process, you'll find that somewhere you're modifying the files outside of Java. There's no reason -- even version changes -- for a file produced by a valid Java compiler to have extra bytes at the end.

提交回复
热议问题