The newest version of J/Link can always be obtained from http://www.wolfram.com/solutions/mathlink/jlink .
If you are replacing the version of J/Link that came with Mathematica with a newer version that you downloaded from the web, all you need to do is delete the old JLink directory in <Mathematica dir>/AddOns and place the new JLink directory there.
You do not need to modify your CLASSPATH environment variable for J/Link to function normally. It is simply a convenience for users who want to compile or run Java programs from the command line. If you do not set up the CLASSPATH environment variable, then you will have to use the -classpath option every time you compile or run from the command line. Some development tools, such as Borland's JBuilder, do not use the CLASSPATH environment variable to locate classes. You will need to consult the tool's documentation for information.
Microsoft Windows
To set the CLASSPATH on Windows 95 and 98, you can add a line like the following to your autoexec.bat file. The path to your Mathematica directory may be different:
set CLASSPATH=C:\Program Files\Wolfram Research\Mathematica\5.0\AddOns\JLink\JLink.jar;%CLASSPATH%
On Windows NT and 2000, open the Control Panel, select System, click the Environment tab and, in the User Variables section, edit the CLASSPATH variable. Put the full path to JLink.jar at the front, separated from any other components of the CLASSPATH by a semicolon.
Restart your computer for the CLASSPATH changes to take effect (on Windows NT and 2000, you need only restart Mathematica ).
Mac OS X
To set the CLASSPATH, add a line like the following to the .cshrc file in your home directory:
setenv CLASSPATH .:"/Applications/Mathematica 5.0.app/AddOns/JLink/JLink.jar":$CLASSPATH
Linux and UNIX
In csh, the CLASSPATH environment variable is modified with the setenv command. A typical command to put in your .cshrc file might be
setenv CLASSPATH .:/usr/local/Wolfram/Mathematica/5.0/AddOns/JLink/JLink.jar:$CLASSPATH
In sh and ksh, typical commands to put in your .profile file might be:
CLASSPATH = .:/usr/local/Wolfram/Mathematica/5.0/AddOns/JLink/JLink.jar:$CLASSPATH export CLASSPATH
The newest version of J/Link can always be obtained from http://www.wolfram.com/solutions/mathlink/jlink .
If you have an older version of J/Link installed, delete the JLink directory in <Mathematica dir>/AddOns/Applications (or wherever you installed it), and delete all old copies of JLink.jar, wherever they might reside on your system. In particular, if you installed an old version of JLink.jar into your Java installation's jre/lib/ext directory, delete it. JLink.jar should not be installed there. Leave it inside the JLink directory.
Microsoft Windows
Step 1: Move the JLink directory to the AddOns\Applications directory
Move the entire JLink directory into the AddOns\Applications directory in your Mathematica directory. Note that there may already be a "stub" JLink directory in AddOns\Applications, which is empty except for a Documentation directory, and exists only to allow an informative announcement about J/Link to show up in the Help Browser before J/Link is installed. You can overwrite the "stub" directory directory.
Launch Mathematica and select Rebuild Help Index from the Help menu. This will cause the J/Link User Guide to show up in the Help Browser when you click the Add-ons button.
The User Guide has information about what versions of Java are supported, and how to obtain Java for your platform.
Step 2 (Optional): Add JLink.jar to your CLASSPATH
NOTE: The location of JLink.jar within the JLink directory structure was changed in this release. Users of previous versions with CLASSPATH specifications that point at JLink.jar will need to revise them. JLink.jar is now in the JLink directory itself, not JLink/SystemAdditions.
If you are going to be writing Java programs that use J/Link (as opposed to only Mathematica programs), you will probably find it convenient to set up the CLASSPATH environment variable to point to JLink.jar . This is particularly true if you are using command-line tools to compile or run Java programs. If you do not set up the CLASSPATH environment variable, then you will have to use the -classpath option every time you compile or run from the command line. Some development tools, notably Borland's JBuilder, do not use the CLASSPATH environment variable to locate classes. You will need to consult the tool's documentation for information.
To set the CLASSPATH on Windows 95 and 98, you can add a line like the following to your autoexec.bat file (enter this as one line). The path to your Mathematica directory may be different:
set CLASSPATH=C:\Program Files\Wolfram Research\Mathematica\4.1\AddOns\Applications\JLink\JLink.jar;%CLASSPATH%
On Windows NT and 2000, open the Control Panel, select System, click the Environment tab and, in the User Variables section, edit the CLASSPATH variable. Put the full path to JLink.jar at the front, separated from any other components of the CLASSPATH by a semicolon.
If you want to use the Microsoft Java runtime, see the notes for Microsoft Windows under the Obtaining Java section in the User Guide.
Mac OS X
Step 1: Move the JLink directory to the AddOns/Applications directory
Move the entire JLink directory into the following location, where <home directory> is your home directory (typically something like /Users/myusername):
<home directory>/Library/Mathematica/4.1/AddOns/Applications
Launch Mathematica and select Rebuild Help Index from the Help menu. This will cause the J/Link User Guide to show up in the Help Browser when you click the Add-ons button.
Step 2 (Optional): Add JLink.jar to your CLASSPATH
If you are going to be writing Java programs that use J/Link (as opposed to only Mathematica programs), and you will be using the 'java' or 'javac' command-line tools, you will probably find it convenient to set up the CLASSPATH environment variable to point to JLink.jar . If you do not set up the CLASSPATH environment variable, then you will have to use the -classpath option every time you compile or run from the command line. Some development tools, notably Borland's JBuilder, do not use the CLASSPATH environment variable to locate classes. You will need to consult the tool's documentation for information.
To set the CLASSPATH, add a line like the following to the .cshrc file in your home directory (this is all one line):
setenv CLASSPATH .:~/Library/Mathematica/4.1/AddOns/Applications/JLink/JLink.jar:$CLASSPATH
Linux and UNIX
It is strongly recommended that you obtain the most up-to-date version of Java you can (1.3.x as of the time of this writing). Of special importance is whether your Java runtime supports native threads vs. the alternative, "green threads". The performance of J/Link, especially when calling Java from Mathematica, will be much greater with a native threads runtime (also called "kernel threads"). If your Java version is 1.3 or later, it will definitely be using native threads, and you can ignore this issue. See the section Obtaining Java in the User Guide for information about obtaining the latest Java for your platform. To determine what version of Java you have, execute
java -version
from a command line.
Step 1: Move the JLink directory to the AddOns/Applications directory
You need to put the JLink directory in one of two special places. If you want J/Link to be accessible to all users, move the JLink directory into the following location, where <mathematica dir> is the main Mathematica installation directory (typically usr/local/mathematica):
<mathematica dir>/AddOns/Applications
You will probably need root access to do this. To make J/Link accessible only to you, you can move the JLink dir into
~/.Mathematica/4.1/AddOns/Applications
You will not need root access to do this.
Launch Mathematica and select Rebuild Help Index from the Help menu. This will cause the J/Link User Guide to show up in the Help Browser when you click the Add-ons button.
Step 2 (Optional): Add JLink.jar to your CLASSPATH
NOTE: The location of JLink.jar within the JLink directory structure was changed in this release. Users of previous versions with CLASSPATH specifications that point at JLink.jar will need to revise them. JLink.jar is now in the JLink directory itself, not JLink/SystemAdditions.
If you are going to be writing Java programs that use J/Link (as opposed to only Mathematica programs), and you will be using the 'java' or 'javac' command-line tools, you will probably find it convenient to set up the CLASSPATH environment variable to point to JLink.jar . If you do not set up the CLASSPATH environment variable, then you will have to use the -classpath option every time you compile or run from the command line. Some development tools, notably Borland's JBuilder, do not use the CLASSPATH environment variable to locate classes. You will need to consult the tool's documentation for information.
In csh, the CLASSPATH environment variable is modified with the setenv command. A typical command to put in your .cshrc file might be
setenv CLASSPATH ~/.Mathematica/4.1/AddOns/Applications/JLink/JLink.jar:$CLASSPATH
In sh and ksh, typical commands to put in your .profile file might be:
CLASSPATH = ~/.Mathematica/4.1/AddOns/Applications/JLink/JLink.jar:$CLASSPATH export CLASSPATH