Unsupported major.minor version 51.0 -- Java compile & runtime versions

When running your Elastic COBOL application under different environments you may see some variation of:

  • Unsupported major.minor version xx.x

such as

  • Unsupported major.minor version 51.0 (Oracle JVM)
  • JVMCFR003 Bad major version (IBM JVM)
This message often appears on the standard error output when running an Elastic COBOL application using the java command or on the Web page when running the application or transaction under a Java Application Server such as Red Hat JBOSS, Oracle Weblogics, IBM Websphere or Java Servlet Engines such as Apache Tomcat or Eclipse Jetty.
The issue has to do with the difference in Java versions used to compile and run your application.  If you are using the latest version of Eclipse IDE to compile your Elastic COBOL application it will choose the latest "Java compatibility version" on the desktop environment. When you run the application it will use the version of the Java Virtual Machine installed at that location.  The javac (compiler) and the java (runtime) must be the same version or the compiler must be older than the runtime or you need to compile the Java source in such a way that it is compatible with an older version of the JVM.
Oracle currently supports Java version 1.8 and no longer supports earlier versions (1.02, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7).  IBM currently supports versions 1.7 on z/OS and AIX.  To see what version you have on your development and deployment systems enter the command prompt window:
  • javac -version
  • java -version 
Then, check and correct if necessary the version of Java used by Eclipse to compile your application.  Under Window > Preferences > Java > Compiler menu:

The above "compiler compliance level" will cause Eclipse to use the javac option -target 1.7 (generate a class file to be able to run on a potentially-down level Java 1.7 runtime environment) and -source 1.7 (the program uses only this level of language and runtime constructs).  If you use the ecobol command from the command-line or from  make, ant or maven build tools then the Elastic COBOL compiler will normally invoke the Java compiler (javac) after a successful COBOL compile.   The javac from the current $PATH will generate class files compatible with its version, whatever that is. The -source and -target options are not set.  If you know that you will be running a program on a different machine with a different Java virtual machine level, you should compile the generated Java to the down-level version.  You can influence the source/target through two Elastic COBOL options:
  • -out:javaversion 7 -- causes ecobol to generate Java source code compliant with version 1.7 and use javac -source 1.7 -target 1.7 options
  • -script:javac '/usr/myjava/javac -deprecated -source 1.7 -target 1.7' -- causes ecobol to use the indicated command line (with appended classpath) to compile Java source code

Alternatively, you can compile the Java yourself and ask the ecobol command to not generate .class files from .java files with the first of the following options:

  • -out:java -- causes ecobol to generate Java source code, but not invoke the javac compiler afterwards
  • -out:class -- causes ecobol to generate Java source code, then invoke the javac compiler to generate .class files (default)
Note that the Elastic COBOL runtime is compiled to be compatible with Java 1.7 (-source 1.7 -target 1.7).
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • 0

    The jarcheck application here ; is really useful for determining what version each file in a jar is compiled with.

    The following command line with check a jar file doesn't contain anything before 1.1 and after 1.7 : 

    java -ea -jar jarcheck/jarcheck.jar <jar filename> 1.1 1.7

    The jarcheck application is compiled with 1.8 but the source is included for you to recompile with your java compiler and then test.

    Recompile using 


    And then run like this:

    java com.mindprod.jarcheck.JarCheck <jar filename> 1.1 1.7
    Edited by ian
Please sign in to leave a comment.
Powered by Zendesk