Sunday 15 April 2012

Matlab doesn't see changes in java class when recompiled -



Matlab doesn't see changes in java class when recompiled -

i work matlab , seek launch java class it. add together path of java class classpath.txt in matlab. create object of java class helloworld , works perfectly:

o = helloworld; javamethod('main', o);

however, when alter code in helloworld, matlab doesn't see this: need restart matlab work changed code of helloworld.

is there way forcefulness matlab see changes in helloworld without restarting?

i guess tried matlab clear classes without success

if take yair altman "undocumented secrets of matlab-java programming" :

provided didn't alter java class signature, may able away it:

java classes not reloaded automatically matlab, when recompiled outside matlab . reload modified java class, need restart jvm restarting matlab . classes placed on dynamic classpath, can seek matlab’s clear(‘java’) command, while remembering side effect of clearing globals . however, not work (e .g ., if class signature has changed).

apparently, if sense expert java programmer, there potential workarounds:

expert java programmers can seek utilize paul milenkovic’s suggestion proxy classloader, alternative restarting matlab or clearing java . dan spielman explains, “the rough thought create classloader class, , access through classloader . after recompile, kill classloader , create new instance of it, reads recompiled class” .

but bottom line is:

in practice, i suggest restarting matlab after java classes recompiled, when not strictly necessary . may save lot of frustrating debugging , chasing downwards errors happen because matlabkeeps old class in memory.

java matlab class matlab-java

No comments:

Post a Comment