Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

javaclasspath

Return Java class path or specify dynamic path

Syntax

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

Description

javaclasspath displays the static and dynamic segments of the Java® class path.

example

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

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

example

dpath = javaclasspath returns 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 to dpath. Use this syntax to reload Java classes you are actively developing and debugging.

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

example

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

Examples

collapse all

Create a cell array with two path values.

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

Set message flag to display class-loading messages.

javaclasspath('-v1')

Modify path.

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

Display updated dynamic path. MATLAB® adds folders from dpath to the existing path.

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.

javaclasspath('-v0') % Suppress display of class-loading messages
p = javaclasspath
p = 

     {}

If there are no entries on the dynamic path, MATLAB creates an empty cell array.

Input Arguments

collapse all

Path entries, specified as a character vector or cell array of character vectors, to specify for the dynamic path. Converts relative paths to absolute paths.

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

Data Types: char | cell

Path entries, specified as a character vector or cell array of character vectors, concatenated, to specify for the dynamic path.

Data Types: char | cell

Message flag, 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.

Controls status message display from the javaclasspath, javaaddpath, and javarmpath functions.

Output Arguments

collapse all

Dynamic path entries for the current path, returned as a cell array of character vectors. If no path entries are defined, dpath is an empty cell array.

Static path entries for the current path, returned as a cell array of character vectors. If no path entries are defined, spath is an empty cell array.

All path entries, returned as a cell array of character vectors. If no path entries are defined, jpath is 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 file javaclasspath.txt.

The static Java path offers better Java class-loading performance than the dynamic Java path. However, to modify the static Java path, edit the file javaclasspath.txt and restart MATLAB. For more information, see Static 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 the javaclasspath function. 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.

To define the dynamic path, use javaclasspath.

To modify the path. use javaaddpath and javarmpath.

To refresh the Java class definitions for all classes on the dynamic path without restarting MATLAB, use clear java.

For more information, see Dynamic Path.

Tips

  • MATLAB searches the static path before the dynamic path.

  • Java classes on the static path should not have dependencies on classes on the dynamic path. Such dependencies produce run-time errors.

  • The clear command clears the definitions of all Java classes defined by files on the dynamic class path.

  • MATLAB displays a warning if you add an entry to the dynamic path that is already specified on the static path.

Introduced before R2006a

Was this topic helpful?