Forums > Java

Sharing memory across distinct mxj objects

June 12, 2010 | 12:53 pm


I’m interested in getting some java objecs to share data. A version of this question has come up already in the forum:

Alexandre asked if there’s a way to do it, and Nick responded that he could "Have [his] MXJ classes inherit from, or refer to, some class containing a static data object".

What if the object is changing, though? Right now I’ve got an mxj object with some data, and I’d really like to split it into two objects: one to update the data, and one to perform lookup operations. (Those might seem like natural operations to bundle together, I know. It would take a while to explain, but trust me, tying them together makes things unnecessarily difficult.) Can Max allow one Java object to refer to something *created* by another one? There’s only one JVM instantiated by mxj during a Max session, so the two objects are at least, in some sense, located "near" each other …

I realize I could write the data to a file from the one object, and have the other object read that file. That’s unappealing, though, because I’d have to devise a file format for the data. Is there a simpler way to share memory across mxj objects?


June 12, 2010 | 11:17 pm

As Nick suggested, use a static field.

If you are unaccustomed to access control, I suggest you have a look at the Java tutorials

June 13, 2010 | 1:52 am

Ah, yes. I’m a dope. I had confused "static" for "final". Thanks a lot!

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

Forums > Java