Importing JAVA class to Matlab - Error

5 次查看(过去 30 天)
I am using Matlab 2016b. I compiled a java program, and modified the classpath.txt file in Matlab to include the .class and .jar file created after compiling the java program in Eclipse IDE. When I try to access the Java class in Matlab I get the following error:
Warning: A Java exception occurred trying to load the ITWOM_Release class: Java exception occurred: java.lang.UnsupportedClassVersionError: ITWOM_Release : Unsupported major.minor version 52.0
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$100(Unknown Source)
at java.net.URLClassLoader$1.run(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.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mathworks.jmi.OpaqueJavaInterface.findClass(OpaqueJavaInterface.java:181)
Undefined function or variable 'ITWOM_Release'.

回答(1 个)

David Barry
David Barry 2016-10-3
This is probably a Java version mismatch. It sounds like you might have compiled using a newer version of Java (possibly JDK 1.8) than MATLAB is using (1.7). You will need to adjust your compiler settings in Eclipse and re-compile.

类别

Help CenterFile Exchange 中查找有关 Call Java from MATLAB 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by