0

I opened the class file in notepad. copied the content of it and pasted in another notepad and saved it at with the same class name with the ".class" extention. then I tried to run that new class file and got the errors as.

Exception in thread "main" java.lang.UnsupportedClassVersionError: print : Unsupported major.minor version 8242.8224
        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$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Alexis C.
  • 91,686
  • 21
  • 171
  • 177
Ashish Khatri
  • 493
  • 5
  • 13

2 Answers2

5

Class files are binary files, so you probably copied a corrupted view of it. You don't want to mess with Java class files by hand, unless you are willing to learn the JVM's bytecode.

If you REALLY want to do this, I suggest getting a hex editor that lets you copy and paste.

EDIT

One other thing, there's no value in messing with Java bytecode unless you are writing a compiler or something like Hibernate that really gets dirty with a class file at runtime. Meaning there is literally no normal business case for manipulating bytecode and you are almost invariably going to introduce a series of "WTF WERE YOU THINKING?!" level errors into a library or application if you don't do it right and with a good reason. One particular reason is that Java and JVM bytecode have a relationship much like C/C++ and Assembly. Sure you can disassessmble a C/C++ app and throw in some hand-coded assembly. However chances are you will introduce undebuggable errors into the app (those errors will be related to your hand-jamming bytecode/assembly into the app, not the code from your codebase that you wrote in the high level language).

Mike Thomsen
  • 36,828
  • 10
  • 60
  • 83
-1

This means your javac version is different from your java version. see

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Community
  • 1
  • 1
user847352
  • 153
  • 1
  • 1
  • 5