0

I am compiling a java program which is giving me the following error :

The java class could not be loaded. java.lang.UnsupportedClassVersionError: `bad major version at offset=6`

Now generally,if you compile with source compatible 1.6 you need JRE 6 to execute the program. but right now my class file is compiled in 1.7 and my JRE version is 1.6.

I am not using eclipse or any tool but using a host type shell script to execute the program.

Is there any way to resolve this issue without changing the JRE version ?

divya.trehan573
  • 454
  • 1
  • 12
  • 28
  • 1
    You can try this answer [how do i compile a .java with support for older versions of-java](http://stackoverflow.com/questions/11364761/how-do-i-compile-a-java-with-support-for-older-versions-of-java) – bluemonki Oct 28 '16 at 08:42
  • That would work if i have the source file. I do not have the java file – divya.trehan573 Oct 28 '16 at 09:09
  • you need to change your question then, because you are not compiling a Java program at all, you are trying to run a compiled Java program with an older JRE. – bluemonki Oct 28 '16 at 09:16

1 Answers1

0

java.lang.UnsupportedClassVersionError: `bad major version at occurs when you compile your file in higher version and your JRE is lower than compiled file

% javac -target 1.4 -bootclasspath jdk1.4.2/lib/classes.zip \
             -extdirs "" OldCode.java

ref :http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javac.html

Keval Pithva
  • 600
  • 2
  • 5
  • 21