How to create Bad version set out inward .class file
"java.lang.UnsupportedClassVersionError: Bad version set out inward .class file" is a mutual mistake inward Java programming linguistic communication which comes when y'all effort to run a Java shape file. In our concluding article, nosotros discussed that how to resolve Java.lang.UnSupportedClassVersionError too industrial plant life that it comes when a major too kid version of the shape is non supported past times Java virtual machine or JRE running the program. Though "java.lang.UnsupportedClassVersionError: Bad version set out inward .class file" is piddling dissimilar than that of its manifestation too Cause. UnsupportedClassVersionError is non equally hard equally Java.lang.OutOfMemoryError and neither its solution is equally good complex precisely what is hard is thinking inward the correct administration because the displace of dissimilar types of UnsupportedClassVersionError is different.
Cause of java.lang.UnsupportedClassVersionError: Bad version set out inward .class file
"java.lang.UnsupportedClassVersionError: Bad version set out inward .class file" comes when y'all compile a Java shape inward higher version of Java Compiler too run it on lower version of Java virtual machine or JRE.
java.lang.UnsupportedClassVersionError: Bad version set out inward .class file
To empathise this UnsupportedClassVersionError ameliorate let's reproduce it via a uncomplicated event inward Java:
1) Create Loan.java too compile it alongside JDK 1.6
2) Run Loan.class alongside JRE 1.5.
C:\Program Files\Java\jre1.5.0_06\bin>java -version
java version "1.5.0_06"
C:\Program Files\Java\jre1.5.0_06\bin>java Loan
java.lang.UnsupportedClassVersionError: Bad version set out inward .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
Solution:
Now y'all know that your rootage is compiled for higher version of JRE or Java runtime if it doesn't operate inward JDK 1.5 than effort to run on JDK 1.6 too y'all volition last able to take "Bad version set out inward .class file"
Further Learning
Complete Java Masterclass
Difference betwixt ClassNotFoundException too NoClassDefFoundError inward Java