An easy way to reinstantiate an mxj object ?

Alexandre's icon

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

Adam Murray's icon

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

Alexandre's icon

thanks,

i even didn't think about that..

robotpapier's icon

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?

robotpapier's icon

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

robotpapier's icon

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

Florito's icon

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);
}

Alexandre's icon

> "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.