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?

 채택된 답변

MathWorks Support Team
MathWorks Support Team 2022년 5월 5일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by