clear java seems to reset a complete Java virtual machine. As a protection for you as a developer, Matlab will not perform this action if you have Java objects in memory that will be destroyed by this action.
Ideally, you can define a Matlab element (usually a variable, either in the workspace or in some constant area) that is an instance of the Ice/ConnectionRefusedException class, and clear it. For variables that you have access to (for example, in the workspace), you can simply run clear variablename or for variables held as constants in some other function, you can run clear functionname .
Then try calling clear java again, as you did.
However, it is sometimes difficult to find the place where the abusive object is located. As you know, I restarted Matlab as a fail-safe restart; Of course, this does not work if you want to work with some recently acquired data.
source share