NoClassDefFoundError when trying out [mxj]…

Feb 9, 2013 at 11:16pm

NoClassDefFoundError when trying out [mxj]…

So this is sort of driving me crazy, and apologies if it’s something really stupid.

I’ve decided to play around with [mxj] and to that purpose, wanted to make a decimal to hexadecimal coverter. I have a HexUtil class that has a static decToHex method that already does the job nicely, so I figured it would be perfect to test [mxj].

So my first mxj class is in /Applications/Max6/Cycling ’74/classes/stsmx/util/ and the source looks like this:

import sts.util.HexUtil;
import com.cycling74.max.*;

public class DecToHex extends MaxObject {
    DecToHex() {
        createInfoOutlet(false);
        declareInlets(new int[] { DataTypes.ALL });
        declareOutlets(new int[] { DataTypes.ALL });
    }

[...some more blabla...]

public void inlet(int i) {
	outlet(0,HexUtil.decToHex(i));
    }
}

It compiles fine, and the constructor is called. But as soon as I try to send an int to the shiny new object, Max gives me a NoClassDefFoundError: sts/util/HexUtil

I can use my HexUtil class in any other class just fine, so I’m lost.

#66423
Feb 10, 2013 at 8:56am

What does the package declaration for your HexUtil class look like?

#239118
Feb 10, 2013 at 9:01am

Wait… you’ve declared package stx but put it in directory stsmx ?

#239119
Feb 10, 2013 at 11:00am

Nick: Not quite. HexUtil is a general-purpose class situated entirely elsewhere, it’s just that the subdirectory names are similar. It lives in /Users/stas/java/sts/util. The package declaration is

package sts.util;

DecToHex on the other hand, is in the Cycling ’74/java/classes/stsmx/util subdirectory of the Max6 application directory, which I’ve done in order for [mxj] to find it (which is does). It’s package declaration (which I omitted above) is

package stsmx.util;

It’s sort of weird that no error is caught by the compiler and instead occurs at runtime.

#239120
Feb 10, 2013 at 11:17am

Ah, OK: sorry, I misread that. So I guess MXJ can’t find HexUtil. You’ll either have to put that class file into Cycling '74/classes as well (with the correct directory structure) or modify max.java.config.txt to include the root directory where it can be found.

I don’t know how you’re compiling, but HexUtil must be in the compiler’s classpath – so there is no compile-time error – but it’s not in Max’s classpath at runtime.

#239121
Feb 10, 2013 at 12:30pm

Thanks Nick! I edited max.java.config.txt and it worked. I need to read up on the way Max handles the classpath.

#239122
Feb 10, 2013 at 3:16pm

There’s some cleverness with extending the classpath when actually reading patcher files, but otherwise it’s all pretty obvious.

For managing max.java.config.txt, you might be interested in trying Topherizer: https://github.com/cassiel/topherizer

#239123
Mar 17, 2013 at 11:48am

Nick, some good and bad news
the last status: legend: w7 M(stands for Max; J->Java, y->ok n->no) (y) Java works(?) but in the Max-Window appears class errors
w7: M4.6.3 J y, M6.0.8 J y
osx-10.6.8: M4.6.3 J y, M6.0.8 J n
xp home sp3:M4.6.3 J y, M6.0.8 J y
osx-10.5.8: M4.6.3 J (y), M6.0.8 J(y)

but at 1st this: in my opinion, these c74_people should revise the “writing externals for java.pdf” immediately
an important point is, to advice their users that the classes_paths should be include in filepreferences otherwise
Max 6 can’t recognize the class_paths and fails with “unable to create JVM” right?

in my next reply I’ll send you here the last problem_candidates (mxjpreferences.xml, max.java.config.txt)
in Max v.6 under osx 10.6.8 (SL) and the output by the Max_window

btw, I would be glad that somebody would create some tutorials (not only about mxj mxj~) in german
im Deutschen ist manches einfach klarer und plausibler beschrieben

thanks for help and solutions

#239124
Mar 17, 2013 at 1:40pm

for information: my apologies is it sounds a bit rough, because of my broken english

#239125

You must be logged in to reply to this topic.