Documentation

javaaddpath

Add entries to dynamic Java class path

Syntax

Description

example

javaaddpath(dpath) adds one or more folders or Java® Archive (JAR) files to the beginning of the current dynamic class path. Use the dynamic path when developing and debugging your own Java classes.

example

javaaddpath(dpath,'-end') adds files or folders to the end of the path.

Examples

collapse all

Add Folder to Dynamic Class Path

Display the current dynamic path.

javaclasspath('-dynamic')
		DYNAMIC JAVA PATH

    <empty>

The output reflects your configuration.

Add the current folder.

javaaddpath(pwd)

Display the dynamic path.

p = javaclasspath
p = 
    'c:\work\Java'

The output reflects your current folder.

Append URL to Dynamic Class Path

javaaddpath('http://www.example.com','-end')
p = javaclasspath
p = 
    'c:\work\Java'
    'http://www.example.com'

Input Arguments

collapse all

dpath — Folder or JAR filestring | cell array of strings

Folder or JAR file, specified as a string or cell array of strings, to add to the dynamic path. When you add a folder to the path, MATLAB® includes all files in that folder as part of the path.

Data Types: char | cell

Limitations

  • MATLAB does not support JAR files generated by the MATLAB Compiler SDK™ product.

More About

collapse all

Tips

  • MATLAB provides the dynamic path as a convenience for when you develop your own Java classes. Although the dynamic path offers flexibility in changing the path, Java classes on the dynamic path might load more slowly than classes on the static path. Also, classes on the dynamic path might not behave the same as classes on the static path. If your class does not behave as expected, use the static path.

    After you develop and debug a Java class, add the class to the static path.

  • MATLAB calls the clear java command whenever you change the dynamic path. This command clears the definitions of all Java classes defined by files on the dynamic class path, removes all global variables and variables from the base workspace, and removes all compiled scripts, functions, and MEX-functions from memory.

  • To add folders to the static path, which MATLAB loads at startup, create a javaclasspath.txt file, as described in Static Path.

Introduced before R2006a

Was this topic helpful?