MATLAB Answers

Adam
0

javaaddpath 'objects of...class exist' warning

Asked by Adam
on 3 Jun 2019
I have run into a situation using multiple 3rd party functions from the file exchange. Both of these rely on java classes and both use the dynamic java path. My understanding is that this needs to be the case if I am to use these in a compiled application?
However this runs into problems with a really simple usage case of me having a GUI open which uses one and then running some code which uses the other. This latter function adds its java dependency to the path with javaaddpath at the time it is called. But this runs into problems because of the objects of the other class which still exist in my first GUI so I get the
Warning: Objects of someClass class exist - not clearing java
And then the code fails because it wasn't able to update and pick up the new java class it is about to use.
Obviously having these things on the static path would be preferable, but as mentioned I need these within compiled applications and unless I am misunderstanding, I cannot add these to the static path for these to work (also my internal work colleagues will each have to create a javaclasspath.txt file pointing to the right location on their Matlab development machines which is not ideal - with the dynamic path we use a relative path which is correct for all).
So is there no way around this seemingly simple sounding issue without having to resort to the sledgehammer approach of killing off my first GUI, which has nothing to do with the new code, other than happeninig to have java objects existing, before I can run the code needing to add its other class to the java path?

  0 Comments

Sign in to comment.

0 Answers