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
2012년 4월 12일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB Compiler SDK에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!