Configure Your Java Environment Search Help Documentation Toggle navigation Documentation Home MATLAB Compiler SDK Troubleshooting Functions and Other Reference Release Notes PDF Documentation Configure Your Java Environment On this page Install the Required JDK Set JAVA_HOME Set the CLASSPATH Configure the Native Library Path Variables Configure Your Java Environment Before you can use the generated Java® packages in a Java development environment, you need to ensure that your Java environment is properly configured. You must verify that: Your system uses the same version of the Java Developer's Kit (JDK™) as MATLAB®. JAVA_HOME is set to the folder containing the system's JDK installation. CLASSPATH contains all of the MATLAB library JAR files and the JAR files for the packages containing your compiled MATLAB code. The MATLAB native library paths are properly configured. Note: For updated Java system requirements, including versions of Java Developer's Kit (JDK) and Java Runtime Environment (JRE™), see the supported compiler page at http://www.mathworks.com/support/compilers/current_release/. Install the Required JDK To install the proper version of the JDK: Verify the version of Java your MATLAB installation is using by running the following MATLAB command: version -java Download the matching version Java Developer's Kit (JDK) from http://www.oracle.com/us/technologies/java/standard-edition/overview/index.html. Install the JDK, following the instructions provided by Oracle®. Note: If you are not developing applications or compiling MATLAB code, you can use the Java Runtime Environment (JRE) instead of the JDK. Set JAVA_HOME From the system command prompt, set the system environment variable, JAVA_HOME, to point to your JDK installation. For example on Windows® enter set JAVA_HOME=path_to_Java_install. If you are compiling MATLAB code, verify that MATLAB is reading the correct value of JAVA_HOME. At the MATLAB command prompt, type getenv JAVA_HOME to display the value of JAVA_HOME in use by MATLAB. Verify that the folder containing your Java installation has been added to your system PATH environment variable. For example on Windows enter set PATH=%PATH%;path_to_Java_install. Set the CLASSPATH To build and run a Java application that uses a MATLAB Compiler SDK™ generated component, the system must locate: JAR files containing the MATLAB libraries Packages that you have developed and built Java classes compiled with MATLAB Compiler SDK use classes contained in the com.mathworks.toolbox.javabuilder package. To use the compiled classes, you need to include a file called javabuilder.jar on the Java class path. You can find this file in one of the following folders: MATLAB installed on your system matlabroot/toolbox/javabuilder/jar MATLAB Runtime installed on your system mcrroot/toolbox/javabuilder/jar Note: matlabroot refers to the root folder into which the MATLAB installer has placed the MATLAB files. mcrroot refers to the root folder under which MATLAB Runtime is installed. In addition, you need to add to the JAR files created by the compiler to the class path. Configure the Native Library Path Variables The operating system uses the native library path to locate native libraries that are needed to run your Java class. See the following list of variable names according to operating system: Windows PATH Linux® LD_LIBRARY_PATH Macintosh DYLD_LIBRARY_PATH The native MATLAB or MATLAB Runtime files needed to execute the compiled MATLAB functions called from the Java code must be included on the paths listed by your system's native library path variable. Was this topic helpful? MATLAB Compiler SDK Documentation Troubleshooting Functions and Other Reference Release Notes PDF Documentation Other Documentation MATLAB MATLAB Compiler MATLAB Production Server Documentation Home Support MATLAB Answers Installation Help Bug Reports Product Requirements Software Downloads © 1994-2016 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments