Why am I unable to delete or overwrite Java Archive Files (JARs) after using JAVARMPATH to remove them from the Java classpath in MATLAB 7.3 (R2006b)?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Aug 2009
Commented: Walter Roberson
on 27 Feb 2022
I am doing joint MATLAB & Java development, and often I need to recompile a Java class and recreate the JAR file that MATLAB is using to access the Java classes.
I have found that even after I call JAVARMPATH I cannot overwrite or delete the JAR file in Windows; I receive the following error message:
Cannot delete foobar.jar: It is being used by another person or program.
I expected to be able to overwrite a JAR file with the new version, but was unable to do so because the JAR file was still "being accessed" by MATLAB.
Accepted Answer
MathWorks Support Team
on 25 Aug 2009
The ability to explicity unload Java classes is not available in MATLAB.
MATLAB uses Java's class-loader features to the extent possible to reload new class definitions, while the Java Virtual Machine (JVM) controls when classes get unloaded, and hence whether or not JAR files are released.
If the objects associated with the JAR files are no longer in use, see the Related Solution listed below about forcing Java garbage collection.
1 Comment
Walter Roberson
on 27 Feb 2022
Some discussion of the internal java technology required:
More Answers (0)
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!