0

System: MAC OS X El Capitan 10.11.6 / MATLAB 2016b student version

I am now trying to use the MATLAB compiler SDK to convert MATLAB codes into JAVA packages following the instruction here (https://www.mathworks.com/help/compiler_sdk/java/configure-your-java-environment.html).

For the first step: install the proper version of the JDK. I have downloaded Java 1.7.0_79-b15 and replaced the jre folder in /Applications/MATLAB_R2016b.app/sys/java/jre/maci64 to the one from /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home. This step is to make sure that the JAVA version MATLAB is using is the one I downloaded. I also checked it in MATLAB via

version -java

The second step is to set the system environment variables, JAVA_HOME and PATH. I have done this in terminal by

export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$PATH:/usr/libexec/java_home/bin

in ~/.bash_profile. I checked the results by

echo $JAVA_HOME
echo $PATH

yielding /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home for JAVA_HOME.

The question is here: when I tried

getenv JAVA_HOME 

in MATLAB, I got an empty array instead of the direction above. I know that I can set it via setenv but in this case I have to set it up whenever I relaunch MATLAB. Is there ways to solve it?

Thank you.

Jamee Lin
  • 35
  • 4

1 Answers1

0

With the method mentioned in the context, the environment variables are set while calling MATLAB through Terminal. The question here is that this does not work when you want to call MATLAB with GUI application.

If you want the environment variables set globally, you can follow the solution provided in Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?. All the environment variables except for PATH should work. For the PATH variable, it can be done by replacing

<key>MATLAB_USE_USERWORK</key>
<string>1</string>

into

<key>PATH</key>
<string>the_desired_path</key>

under LSEnvironment in Info.plist.

Community
  • 1
  • 1
Jamee Lin
  • 35
  • 4