Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 442 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
UnsupportedClassVersionError When Running JNI

Hello All,
I'm getting a UnsupportedClassVersionError error when calling FindClass() when running my C++ application on RedHat Linux. We're a C++ shop and we're using JNI in order to use a Java library given to us by a third party broker to interface with their systems.
The program had not been recompiled in a couple of years but recently an older C++ library that the program used was deprecated so we had to recompile this program. But now when we try to run the program we're getting this error.
Exception in thread "main" java.lang.UnsupportedClassVersionError: TradingEngineWrapper : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
I tried upgrading to a newer version of the JDK (jdk1.8.0_45) but that didn't help. I know this is caused because our Java class library is compiled with one version but the JRE that is being invoked by the JNI is an incompatible version. My question is, how do I control what version of the JRE that gets called when starting my C++ application? Because I'm calling a C++ application I'm not starting it with "java app_name" or anything like that. Any help would be appreciated.
Thank you.
Answers
-
First, your C++ app, with JNI, is being built with a specific library in use as part of the linker. Insure that that library is the 'correct' java version.
Second your C++ app runs but looking for the libraries via your OS dependent look up strategy for libraries (just like any other library). Insure that the library it finds is for the 'correct' java version. This of course should be the same as what you are using above.
Finally make sure that you have not installed different versions of java into the same location. Or worse, manually copied different parts of java (like random libraries) into unusual places.