External Interfaces Previous page   Next Page

Using a Different Version of the Java JVM

MATLAB ships with one specific version of the Java Virtual Machine (JVM) and uses this version by default with the MATLAB interface to Java. This section describes how to download and select a version other than the default.

To change the JVM version that MATLAB uses, follow these steps:

  1. Download the JVM Version You Want to Use.
  2. Locate the Root of the Run-time Path for this Version.
  3. Set the MATLAB_JAVA Environment Variable to this Path.

When you have enabled a different version of the JVM, you can verify that MATLAB is using this version by entering the version -java command documented in the previous section.

Download the JVM Version You Want to Use

You can download the Java Virtual Machine from the Web site http://java.sun.com/j2se/downloads.html.

If you are using Linux, go to the Web site http://www.blackdown.org/java-linux/mirrors.html, and choose the version required by your processor.

Locate the Root of the Run-time Path for this Version

To get MATLAB to use the version you have just downloaded, you must first find the root of the run-time path for this JVM, and then set the MATLAB_JAVA environment variable to that path. To locate the JVM run-time path, find the directory in the Java installation tree that is one level up from the directory containing the file rt.jar. This may be a subdirectory of the main JDK install directory. (If you cannot find rt.jar, look for the file classes.zip.)

For example, if the JDK is installed in D:\jdk1.2.1 on Windows and the rt.jar file is in D:\jdk1.2.1\jre\lib, you would set MATLAB_JAVA to the directory one level up from that: D:\jdk1.2.1\jre.

On UNIX, if the JDE is installed in /usr/openv/java/jre/lib and the rt.jar is in /usr/openv/java/jre/lib, set MATLAB_JAVA to the path /usr/openv/java/jre.

Set the MATLAB_JAVA Environment Variable to this Path

The way you set or modify the value of the MATLAB_JAVA variable depends on which platform you are running MATLAB on.

Windows NT/2000/XP.   To set MATLAB_JAVA on Windows NT, Windows 2000, or Windows XP,

  1. Click Settings in the Start Menu
  2. Choose Control Panel
  3. Click System
  4. Choose the Environment tab on Windows NT or the Advanced tab on Windows 2000 or XP, and then click the Environment Variables button.
  5. You now can set (or add) the MATLAB_JAVA system environment variable to the path of your JVM.

For UNIX/Linux.   To set MATLAB_JAVA on UNIX or Linux systems,

Use the setenv command, as shown here:


Previous page  Using Java from MATLAB: An Overview Bringing Java Classes and Methods into MATLAB Next page

© 1994-2005 The MathWorks, Inc.