Forums > Java

Trouble getting MXJ to work.

February 25, 2012 | 2:15 pm

I’m trying to get this piece of Java to load into MXJ – it compiles fine, but when I go to make an [mxj] object to host it, I get java.lang.NoClassDefFoundError: meansink (wrong name: list/Meansink). Any idea why? Why does my classes disappear? it’s still in the same spot as all the other java things – and yes I’ve restarted Max in the hopes of restarting the max JVM, no luck.

–java code–

package list;
import com.cycling74.max.*;

public class Meansink extends ListProcessor {

int howMany = 1;
float[] theList;

Meansink(Atom[] a) {
declareIO(2,1);
declareAttribute("howMany");
if (a.length >0)
howMany = a[0].toInt();
else
howMany = 100;
}

public void loadbang(){
setLen(howMany);
}

protected void input(int idx, Atom[] a) {
switch (idx) {
case 0: streamAlong(a); break;
case 1: setHowMany(a); break;
}
}

public void setHowMany(Atom[] a) {
howMany = a[0].toInt();
setLen(howMany);
}

public void setLen(int i){

theList = new float[i];
}

public void streamAlong(Atom[] a) {

for( int i = 1; i

theList[i] = theList[i-1];
}
theList[0] = a[0].toFloat();
setOutput(0, Atom.newAtom(theList));
}

}

–/java code/–

Thoughts?


February 25, 2012 | 2:17 pm

Figure I might as well attach a file.

Attachments:
  1. Meansink.java


Jan
February 25, 2012 | 2:29 pm

Hi MuShoo,

mxj classes must extend from MaxObject.

Jan


February 25, 2012 | 10:41 pm

except for that all the mxj list.* objects extend from ListProcessor. Which is an extension of MaxObject. So yes, I am extending from MaxObject.


February 25, 2012 | 11:04 pm

OK durr.

Figured it out – I’m using ListProcessor – which is an extension of MaxObject, from within the list package – so I have to instantiate as list.Meansink.

Doi.


February 28, 2012 | 2:25 pm

Another way to say this is: you placed the class in the list package, therefore it has to be instantiated with the full path, list.Meansink. This would apply to any Java class. If you simply remove the package statement at the top of your code you’ll be able to instantiate the class as you were trying to.


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