Forums > Java

An easy way to reinstantiate an mxj object ?

June 11, 2008 | 4:16 pm

Hi,

i was wondering if someone found a particular alternative to the "clic-three-times-on-the-object–erase-one-letter–retype-the-letter–clic-in-the-patch-window" machinery each time we recompile the java code ?

thanks,
Alexandre


June 11, 2008 | 8:27 pm

I think the easiest way is to delete the object, then undo.


June 12, 2008 | 12:04 pm

thanks,

i even didn’t think about that..


December 27, 2009 | 1:28 pm

Hi,
I’m patching with max 5.1.
Need to set
mxj.classloader.fromdisk 1 in the max.java.config.txt file

In the java doc, it says that we can send a zap message to reinstantiate the class file but it doesn’t do anything . I’ve also tried with _zap, and nothing.
Did anyone got the zap message to work or found a way so the mxj automatically loads from the disk?


December 27, 2009 | 2:09 pm

Re,
I made more tests,
in fact, the delete and undo trick works even if fromdisk is set to 0.
But for me it only works if I send a zap message then delete and then undo.
Not very pragmatic.

I wish there was a "autowtch" like in js but for mxj


January 12, 2010 | 6:05 pm

re, i found a trick, i wrote a js that delete and build the mxj object in one click.


January 13, 2010 | 9:51 pm

I had the same problem (running on a Windows XP). Once I found the zap command it worked for me.

A good solution for checking if you have the latest version is to let your java object output the compile date when it’s instantiated.

My java MaxObject’s always call a method called postversion() on instantiation. This method only works if you compile to classes and not to jars.


public void postversion() {
String VERSION = "";
try {
Date modDate = new Date(getClass().getResource(getClass().getSimpleName()+".class").openConnection().getLastModified());<
VERSION = "modified "+modDate;
} catch (IOException e) {
e.printStackTrace();
}
post(getClass()+", VERSION "+VERSION);
}


March 2, 2010 | 7:06 pm

> "But for me it only works if I send a zap message then delete and then undo."

the java-doc tells the zap msg is only interesting when using more than one mxj object of the same class. I do this rather rarely. if you only have one mxj of your class in a patch, you don’t need the zap message. I never used it and the "delete-then-undo" works for me.

But i still dream about a "reinstantiate" message feature in mxj.


Viewing 8 posts - 1 through 8 (of 8 total)