MATLAB Answers

LEW1102
1

Can I use the SDK Compiler in 2015a with a version of Java that didn't come with MATLAB?

Asked by LEW1102
on 7 Dec 2015
Latest activity Commented on by ZBMedina
on 29 Mar 2016
I would like to wrap my MATLAB code into a Java class using the MATLAB Compiler SDK. MATLAB version 2015a is shipped with an older version of Java - more specifically Java 1.7.0_60. I downloaded and installed Java 1.7.0_60 and then configured my Java environment and was able to successfully generate a .jar file. However, it turns out that Java 1.8.0_66 is the only version of Java approved to be on my computer.
I tried adding a MATLAB_JAVA environment variable as described here: http://www.mathworks.com/matlabcentral/answers/130359-how-do-i-change-the-java-virtual-machine-jvm-that-matlab-is-using-on-windows and pointed it to the following directory: C:\Program Files\Java\jre1.8.0_66. However, when I open MATLAB I see many errors caused by java.lang.RuntimeException: XPathFactory#newInstance().... Additionally, when I go to select Library Compiler from Apps, the content within the window never loads.
Is there a potential work-around here? Is it possible to set MATLAB_JAVA to point to a newer version of Java without compromising the use of the SDK Compiler?

  1 Comment

I'm having the same problem with Matlab 2015b and JDK 1.8. Older version of JDK are no longer approved on any PC on the network. Please let me know if you have found a solution.

Sign in to comment.

1 Answer

Answer by Harsheel
on 7 Dec 2015

What you are doing is changing the JAVA version for MATLAB and all the toolboxes. You don't need to do that, revert this change.
For Compiler SDK, create an environment variable JAVA_HOME and set it to the JDK path. What you have installed is JRE. Please install the JDK. For example, JAVA_HOME will look like:
C:\Program Files\Java\jdk1.7.0_60
This will ensure that Compiler SDK uses JDK 1.7 to convert the .m files into .jar files. Meanwhile, MATLAB and other products will continue to use JRE 7 that is shipped with MATLAB.
More info can be found here

  2 Comments

Hi Harsheel, I would like to clarify my previous post. Prior to today, I had found the link you provided and followed all of the steps and had success. However, my system got black listed last week when a scan reported that I had installed JDK 1.7.0_60. As a result, I had to remove this version of Java from my machine. The only JDK allowed on my system is 1.8.0_66. Now, I am trying to repeat what I was able to do before, but with JDK 1.8.0_66 installed on my machine. If I set JAVA_HOME to the following: C:\Program Files\Java\jdk1.8.0_66 I get errors during packaging. If an error log would be helpful, let me know and I can attach one. Here is what I'm trying to figure out: Is it possible use the compiler to create a Java package with my new version of Java (1.8.0_66)?
Unfortunately, this is currently not supported. You need to exactly have JDK 1.7.0_60.

Sign in to comment.