Skip to Main Content Skip to Search
Product Documentation

javarmpath - Remove entries from dynamic Java class path

Syntax

javarmpath(dpath)
javarmpath(dpath1,...,dpathN)
javarmpath(v1,...,vN)

Description

javarmpath(dpath) removes specified file or folder from the current dynamic Java path.

javarmpath(dpath1,...,dpathN) removes multiple files or folders.

javarmpath(v1,...,vN) removes files or folders specified as MATLAB variables.

Tips

The Java path consists of two segments: a static path (read only at startup) and a dynamic path. The MATLAB software always searches the static path (defined in classpath.txt) before the dynamic path. Java classes on the static path should not have dependencies on classes on the dynamic path. Use javaclasspath to see the current static and dynamic Java paths.

MATLAB calls the clear java command whenever you change the dynamic path.

Path Type

Description

Static

Loaded at the start of each MATLAB session from the file classpath.txt. The static Java path offers better Java class loading performance than the dynamic Java path. However, to modify the static Java path you need to edit the file classpath.txt and restart MATLAB.

Dynamic

Loaded at any time during a MATLAB session using the javaclasspath function. You can define the dynamic path (using javaclasspath), modify the path (using javaaddpath and javarmpath), and refresh the Java class definitions for all classes on the dynamic path (using clear java) without restarting MATLAB.

Input Arguments

dpath

String specifying a file or folder.

dpath1,...,dpathN

Strings specifying multiple files or folders.

v1,...,vN

One or more MATLAB variables containing file or folder names.

Examples

This example demonstrates modifying the dynamic Java class path.

  1. Create a function to set your initial dynamic class path:

    function setdynpath
    javaclasspath({
       'C:\Work\Java\ClassFiles', ...
       'C:\Work\JavaTest\curvefit.jar', ...
       'C:\Work\JavaTest\timer.jar', ...
       'C:\Work\JavaTest\patch.jar'});
    % end of file 
    
  2. Call this function to set up your dynamic class path and then display all current static and dynamic paths:

    setdynpath;
    
    javaclasspath
    
           STATIC JAVA PATH
    
       D:\Sys0\Java\util.jar
       D:\Sys0\Java\widgets.jar
       D:\Sys0\Java\beans.jar
                 .
                 .
    
           DYNAMIC JAVA PATH
    
       C:\Work\Java\ClassFiles
       C:\Work\JavaTest\curvefit.jar
       C:\Work\JavaTest\timer.jar
       C:\Work\JavaTest\patch.jar
    
  3. Add the following entries to the dynamic path. One entry specifies a folder and the other a Java Archive (JAR) file. When you add a folder to the path, MATLAB includes all files in that folder as part of the path:

    javaaddpath({
       'C:\Work\Java\Curvefit\Test', ...
       'C:\Work\Java\mywidgets.jar'});
    
  4. Display the dynamic path:

    p = javaclasspath
    p = 
       'C:\Work\Java\ClassFiles'
       'C:\Work\JavaTest\curvefit.jar'
       'C:\Work\JavaTest\timer.jar'
       'C:\Work\JavaTest\patch.jar'
       'C:\Work\Java\Curvefit\Test'
       'C:\Work\Java\mywidgets.jar'
    
  5. Create an instance of the mywidgets class that is defined on the dynamic path:

    h = mywidgets.calendar;
    
  6. If you modify one or more classes defined on the dynamic path, you must clear the former definition for those classes from MATLAB memory. To clear all dynamic class definitions, type:

    clear java
    

    If you then create a new instance of one of these classes, MATLAB uses the latest definition of the class to create the object.

  7. Remove mywidgets.jarfrom the current dynamic class path:

    javarmpath('C:\Work\Java\mywidgets.jar');
    

See Also

clear | javaaddpath | javaclasspath

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS