Documentation

javaclasspath

ReturnJavaclass path or specify dynamic path

Syntax

javaclasspath
javaclasspath('-dynamic')
javaclasspath('-static')
dpath = javaclasspath
spath = javaclasspath('-static')
jpath = javaclasspath('-all')
javaclasspath(dpath)
javaclasspath(dpath1,dpath2)
javaclasspath(statusmsg)

Description

javaclasspathdisplays thestaticanddynamicsegments of the Java®class path.

example

javaclasspath('-dynamic')displays the dynamic path.

javaclasspath('-static')displays the static path.

example

dpath= javaclasspathreturns the dynamic path,dpath.

spath= javaclasspath('-static')returns the static path,spath.

jpath= javaclasspath('-all')returns the entire path,jpath. The returned cell array contains first the static segment of the path, and then the dynamic segment.

example

javaclasspath(dpath)changes the dynamic path todpath. Use this syntax to reload Java classes that you are actively developing and debugging.

javaclasspath(dpath1,dpath2)changes the dynamic path to the concatenation of pathsdpath1,dpath2.

example

javaclasspath(statusmsg)enables or disables the display of status messages.

Examples

collapse all

Use a cell array to add folders to an existing Java class path.

Create a cell array with two path values.

dpath = {'http://domain.com','http://some.domain.com/jarfile.jar'};

Set the message flag to display the class-loading messages.

javaclasspath('-v1')

Add the paths indpathto the class path.

javaclasspath(dpath)
Loading following class path(s) from local file system: * http://domain.com * http://some.domain.com/jarfile.jar

Display the updated dynamic path. MATLAB®adds folders fromdpathto the existing path. The output depends on your system configuration.

javaclasspath('-dynamic')
DYNAMIC JAVA PATH http://domain.com http://some.domain.com/jarfile.jar

Create a cell array,p, with the entries of the dynamic path. If there are no entries on the dynamic path, then MATLAB creates an empty cell array.

javaclasspath('-v0')% Suppress display of class-loading messagesp = javaclasspath
p = {}

Input Arguments

collapse all

Path entries, specified as a string, an array of strings, a character vector, or a cell array of character vectors for the dynamic path. MATLAB converts relative paths to absolute paths.

Example:javaclasspath('http://domain.com')

Data Types:char|cell

Path entries, specified as a string, an array of strings, a character vector, or a cell array of character vectors concatenated for the dynamic path.

Data Types:char|cell

佛罗里达州消息g, specified as one of these values.

'-v0'

Do not display status messages when loading the Java path from the file system.

'-v1'

Display status messages.

Thestatusmsgargument controls status message display from thejavaclasspath,javaaddpath, andjavarmpathfunctions.

Output Arguments

collapse all

Dynamic path entries for the current path, returned as an array of strings or a cell array of character vectors. If there are no path entries, thendpathis an empty cell array.

Static path entries for the current path, returned as an array of strings or a cell array of character vectors. If there are no path entries, thenspathis an empty cell array.

All path entries, returned as an array of strings or a cell array of character vectors. If there are no path entries, thenjpathis an empty cell array.

More About

collapse all

Static Path

The static path is a segment of the Java path that is loaded at the start of each MATLAB session from the MATLAB built-in Java path and the filejavaclasspath.txt.

MATLAB searches the static path before the dynamic path.

The static Java path offers better Java class-loading performance than the dynamic Java path. To modify the static Java path, edit the filejavaclasspath.txtand restart MATLAB. For more information, seeStatic Path.

Dynamic Path

The dynamic path is a segment of the Java class path.

MATLAB provides the dynamic path as a convenience for when you develop your own Java classes. You can load the dynamic path any time during a MATLAB session using thejavaclasspathfunction. 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 way as classes on the static path. If your class does not behave as expected, then use the static path. After you develop and debug a Java class, add the class to the static path.

  • To define the dynamic path, usejavaclasspath.

  • To modify the path. usejavaaddpathandjavarmpath.

  • To refresh the Java class definitions for all classes on the dynamic path without restarting MATLAB, useclearjava.

For more information, seeDynamic Path.

Tips

  • 不要把Java类的静态路径哈ve dependencies on classes on the dynamic path. Such dependencies produce run-time errors.

  • To clear the definitions of all Java classes defined by files on the dynamic class path, call theclearcommand.

  • Adding an entry to the dynamic path when it is already specified on the static path produces a warning.

Introduced before R2006a

Was this topic helpful?