您的位置:首页 > 编程语言 > MATLAB

How do I change the Java Virtual Machine (JVM) that MATLAB is using?

2013-05-24 11:22 1426 查看
Date Last Modified: Thursday, May 3, 2012
Solution ID:1-1812J
Product:MATLAB
Reported in Release:No Release
Fixed in Release:R2012a
Platform:All Platforms
Operating System:All OS


Subject:

How do I change the Java Virtual Machine (JVM) that MATLAB is using?


Problem Description:

I would like to use a different version of JVM than the default used in MATLAB.


Solution:

MATLAB ships with one specific version of the JVM software on all operating systems, except Apple Mac OS® X operating systems. On Mac OS X systems, MATLAB uses the JVM software provided with the operating system.

Note MATLAB is only fully supported on these versions of the JVM software. Some components might not work properly under a different version of the JVM software. For example, calling functions in a dynamically linked library that was created with a different
JVM software version than that used by MATLAB might cause a segmentation violation error message.

If you choose to change the JVM software version, you must:

- Locate the root directory of the runtime path for the version of JVM software that you want to use.

- Set the MATLAB_JAVA Environment Variable to this path.

Note1: On the Mac platform the MATLAB_JAVA environment variable cannot be used to modify the JVM that is being used by MATLAB.

Note 2: The architecture of the JVM must match the architecture of the installed MATLAB. If you use a 64-bit version of MATLAB for Windows, you need to have a 64-bit Windows version of the JVM installed. You can use the following command to find out which architecture
your MATLAB version is:

computer('arch')


There are two ways to have a JVM installed: a JRE (the runtime), or a JDK (which includes the JRE and a development environment). The MATLAB_JAVA variable should point to the root of the runtime, which may actually be in a subdirectory of the full JDK. Find
the file named rt.jar under your Java installation. The directory that contains the directory that contains rt.jar is the one that you need. For example if rt.jar has the following path:

C:\Program Files\Java\jre6\lib\rt.jar

you should set the MATLAB_JAVA environment variable to:

C:\Program Files\Java\jre6

Note 3: To locate the JVM path in Unix/Linux, open a UNIX shell and type the following command:

$locate rt.jar
You will see the complete path information of 'rt.jar' file. There could be more than one 'rt.jar' file based on the different Java versions installed in your machine. Set MATLAB_JAVA variable to point to the Java version that you want to use.

For example, 'rt.jar' file may have the following path:

/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/rt.jar

In that case, set the MATLAB_JAVA environment variable to :

/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

The steps needed to set the MATLAB_JAVA system environment variable are listed below.

For Windows :

*******************

Click Start

Right click Computer and choose Properties

Click Advanced System Settings and then click the Environment Variables button.

You now can set (or add) the MATLAB_JAVA system environment variable to the path of your JVM software.

For UNIX/Linux:

*******************

On Unix csh or tcsh shells use the SETENV command to set the MATLAB_JAVA environment variable. For example:

setenv MATLAB_JAVA <path to JVM>
On Unix bash shell: In the shell, type:

export MATLAB_JAVA=<path to JVM>
To verify that MATLAB is using the correct version of the JVM software, type the following at the MATLAB prompt:

version –java


Please note that restarting the machine after the changes made is recommended for the changes to work correctly.

For reverting back to previous java runtime, the discussions at the following link might be useful:

http://discussions.apple.com/thread.jspa?threadID=1936578&tstart=1

Also see the Related Solution listed below.


Related Solutions:

Why do I receive errors when trying to launch MATLAB 6.0 (R12) on a Pentium IV machine?

How can I upgrade the JVM from 1.5.0_13 to 1.6 that MATLAB 7.6 (R2008a) uses on my 64-bit Intel Mac running Leopard
10.5.x?

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐