Supported Platform: Linux® only.
Before you can interactively debug your applications using the MATLAB® API for Spark™, you must configure your MATLAB environment by adding the location of the Spark assembly jar to the front of MATLAB's static Java class path.
A Spark assembly JAR file includes all the Spark dependencies, including some internal Hadoop® dependencies. This JAR file is created during Spark installation and is specific to a particular combination of
Spark and Hadoop versions. For example, using Spark version 1.4.0 and Hadoop version 2.4.0 creates the file
spark-assembly-1.4.0-hadoop2.4.0.jar
.
To add the location of the Spark assembly jar to the front of MATLAB’s static Java® class path, use the following procedure:
Open a Linux terminal.
Navigate to the directory
,
where <matlabroot>
/bin
is the
location where MATLAB is
installed. <matlabroot>
Set the environment variable SPARK_HOME
to point to the
Spark installation directory. For example:
Shell | Command |
---|---|
csh / tcsh |
% setenv SPARK_HOME /share/spark |
bash |
$ export SPARK_HOME=/share/spark |
From the directory
execute the shell script <matlabroot>
/bingeneratesparkjcpath
. For
example:
$ ./generatesparkjcpath
This will create a file called javaclasspath.txt
in
your
directory. The contents of a sample <matlabroot>
/binjavaclasspath.txt
file look like
this:
<before> /share/spark/conf/ /share/spark/lib/spark-assembly-1.4.0-hadoop2.4.0.jar /share/spark/lib/datanucleus-rdbms-3.2.9.jar /share/spark/lib/datanucleus-api-jdo-3.2.6.jar /share/spark/lib/datanucleus-core-3.2.10.jar
The <before>
tag ensures that
spark-assembly-1.4.0-hadoop2.4.0.jar
is added to the
front of the Java class path.
Start MATLAB from the
directory.<matlabroot>
/bin
You can create the javaclasspath.txt
file in a directory
other than
by
specifying the <matlabroot>
/bin-o
option. The file has to be named
javaclasspath.txt
. For
example:
$ ./generatesparkjcpath -o /home/user/javaclasspath.txt
/home/user
. It is important that you start MATLAB from the directory containing the
javaclasspath.txt
file. You can verify whether spark-assembly-1.4.0-hadoop2.4.0.jar
was
added to the front of the Java class path by typing the following at the MATLAB command
prompt:
>> spath = javaclasspath('-static') ;
>> spath(1:5)
/share/spark/lib/spark-assembly-1.4.0-hadoop2.4.0.jar
on the top of the list.You need to complete this configuration just once. Subsequent usage only requires
that you start MATLAB from the folder
containing the javaclasspath.txt
file.