본문 바로가기

카테고리 없음

java.lang.UnsupportedClassVersionError: Bad version number in .class file

반응형
java.lang.UnsupportedClassVersionError: Bad version number in .class file
 at java.lang.ClassLoader.defineClass1(Native Method)
 at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
 at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
 at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
 
흠.. 간만에 AMSMain을 실행 시켰더니 저런 에러가 나는군..
 
구글링....
 
http://lkamal.blogspot.com/2008/04/javalangunsupportedclassversionerror.html
 
java.lang.UnsupportedClassVersionError: Bad version number in .class file
[at java.lang.ClassLoader.defineClass1(Native Method)]
is an error that you may face in running a compiled java class file.


So as you can see from the stack trace, a class has not been loaded. But which class? The problem is this error message does not show the name of the failed .class, isn't it?

No, it is not. This error is caused when you compile a .java file with one version of JDK and running the .class file with a different version of JVM.

Confused? You may say; same version is not required to compile and run.

Yes, that is true. But you can not run .class files that are compiled with a newer version than the JVM.

Say;
javac (compile) - version: X
java (run) - version: Y
If X is newer than Y; then you may face this issue at runtime.
 
컴파일 할 때와 실행 할 때의 jdk 버전이 달라서 나는 에러라고 한다.

Thanks Kamal.
반응형