Error of unsupported class version

When I try to call an EJB created using NETbeans (using jdk1.7) from a client created using the Eclipse IDE (using jdk1.6), I get the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: stateless/TestEjbRemote : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:688) at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:463) at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:414) at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:392) at Main.main(Main.java:19) 

Any solution to this problem?

+6
source share
4 answers

Try changing the target version of JRE to 1.6 in the build configuration.

+14
source

The problem was: I called EJB using jdk1.7 from a client that used jdk1.6. Switch jdk1.7 to jdk 1.6, it worked. or you can switch jdk1.6 to 1.7, then this will also work. The output can be called by any EJB that uses both the same version or a minor version of jdk as the caller.

+1
source

I had the same problem, but I used a text panel. The solution was quite simple. Try to put the class in a conflict in another place (for example, in the backup folder) or simply delete it if it does not exist in the same directory. Then try compiling the java file so that you can create a new class that matches the specifications of your computer. Try it if it works for you because it worked for me. :)

+1
source

The second time I had a problem, just change the build configuration of this project. Right-click the name of your project → [properties] → [java compiler] → [Enable special project settings] → set [compiler compliance level] to 1.7

Eclipse has its own compiler, no matter what version of javac (jdk) is on your system, so you must first configure the version of the eclipse compiler.

Link: java.lang.UnsupportedClassVersionError: bad version number in .class file?

0
source

Source: https://habr.com/ru/post/907369/


All Articles