Is it possible to link my custom Java code (compiled with JDK 1.5), with a MATLAB Builder JA deployed component compiled using JDK 1.6?

3 次查看(过去 30 天)
I am using MATLAB Builder JA 2.2 (R2010b) to compile a deployed JAR component. However, since MATLAB 7.11 (R2010b) uses the Java Runtime Environment (JRE) 1.6, the deployed components must also be compiled with Java Development Kit (JDK) 1.6.
I need to link the deployed components with my own existing Java libraries that were developed using JDK 1.5. But I run into various errors due to this version mismatch. How can I make this work?

采纳的回答

MathWorks Support Team
It is possible to make this setup work, but there are guidelines that must be adhered. Suppose that myLib1_5.jar was my library compiled with JDK 1.5, and matLib1_6.jar was the MATLAB deployed component compiled with JDK 1.6.
1. Java libraries compiled with older JDK versions cannot call libraries compiled with newer versions. So classes from myLib1_5.jar cannot call functions or classes from matLib1_6.jar.
2. Java libraries compiled with newer JDK versions may call libraries compiled with older versions.
3. Minor Java updates within a version such as 1.6.0-20 vs. 1.6.0-17 should not cause issues.
As such, there are two options to make the setup work:
1. Write a driver class, compiled in the newer version, that calls both the older version and the newer deployed component. For example, if myDriver1_6.class is my driver class compiled using JDK 1.6, it can call both myLib1_5.jar and matLib1_6.jar.
2. Call the older libraries from within MATLAB code using MATLAB's Java external interface, then deploy the whole component. For example, myLib1_5.jar is imported and utilized from the MATLAB code foo.m. Then foo.m is compiled into matLib1_6.jar using MATLAB Builder JA and JDK 1.6.
Please note that attempting to start MATLAB with an earlier version of JRE (setting MATLAB_JAVA environment variable to JRE 1.5), or attempting to compile the deployed component using an older JDK version (setting JAVA_HOME environment variable to JDK 1.5) are not possible.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB Compiler SDK 的更多信息

产品


版本

R2010b

Community Treasure Hunt

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

Start Hunting!

Translated by