We are facing an issue when removing a directory from MATLAB path after adding jar-file paths to dynamic javapath:
* The task is to add several folders to MATLAB Path. These folders also contain .jar-files
* Regarding java, we add the full directory paths of .jar files to the dynamic java path
* Later these paths shall be removed again
* In addition, we remove the directory containing these files from MATLAB path again
* We want to delete the directory containing the jar files via rmdir()
However, the last step of rmdir() is not possible as the jar files are not removed properly from the path.
Is there any way to achieve the removal of jar files from path so the directory can be removed via rmdir?

 Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 5 Mai 2022

0 Stimmen

In order to remove jar files properly, java garbage collection must be used:
cellDynPath = javaclasspath('-dynamic');
javarmpath(cellDynPath{:});
java.lang.System.gc();
cellfun(@(x)rmpath(x), cellDynPath)
java.lang.System.gc(); % using gc twice is required

Weitere Antworten (0)

Kategorien

Produkte

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by