How to clean the dynamic java path properly?

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?

 Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Productos

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by