When running your Elastic COBOL application under different environments you may see some variation of:
- Unsupported major.minor version xx.x
- Unsupported major.minor version 52.0 (Oracle JVM)
- Unsupported major.minor version 51.0 (Oracle JVM)
- JVMCFR003 Bad major version (IBM JVM)
This message 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 when the version of java you have installed is out-of-date and no longer supported by the Java vendors.
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.
Note: External Java version numbering changed after what was known as Java 1.7. The next version was Java 8. The internal version numbering is remaining consistent. Java 1.7 has internal version number 52.0 and Java 8 has internal version number 53.0.
Oracle currently support Java versions 8 (a.k.a 1.8, a.k.a 53.0) and 9 (a.k.a. 1.9, a.k.a 54.0) 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 with a support contract, but prefer you upgrade to the latest version. 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 8
(generate a class file to be able to run on a potentially-down level Java 1.7 runtime environment) and -source 8
(the program uses only this level of language and runtime constructs). If you use the ecobol
command from the command-line or from make
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
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 8 -- causes ecobol to generate Java source code compliant with version 1.8 and use javac -source 8 -target 8 options
- -script:javac '/usr/myjava/javac -deprecated -source 8 -target 8' -- 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.8 and higher (-source 8 -target 1.8).