필터 지우기
필터 지우기

Configure the JAVA environment on Mac

조회 수: 11 (최근 30일)
Jamee Lin
Jamee Lin 2017년 3월 29일
댓글: Jamee Lin 2017년 4월 4일
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.
  댓글 수: 1
Varun Gunda
Varun Gunda 2017년 4월 3일
Having setenv in startup.m file may help you

댓글을 달려면 로그인하십시오.

답변 (1개)

Sangeetha Jayaprakash
Sangeetha Jayaprakash 2017년 4월 3일
I assume that you are using the "export" command in a bash shell. Using export command on terminal, will just setup the environment variable for that session of the terminal. So, make sure to launch MATLAB from the same terminal session.
To make the environment variable permanent, add the export statement in "./bash_profile".
  댓글 수: 1
Jamee Lin
Jamee Lin 2017년 4월 4일
Yes, I have noticed this. As I mentioned in the context, I put export statements in ./bash_profile. This only allows the environment variables being set in Terminal. That is said I have to open MATLAB via Terminal in order to use these set variables.
I am now trying to build up the system-wide environment variables so that all the settings are still available for GUI applications.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Java Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by