Forums Java
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.
What does the package declaration for your HexUtil class look like?
Wait… you’ve declared package stx but put it in directory stsmx ?
stx
stsmx
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.
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.
HexUtil
Cycling '74/classes
max.java.config.txt
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.
Thanks Nick! I edited max.java.config.txt and it worked. I need to read up on the way Max handles the classpath.
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:
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
for information: my apologies is it sounds a bit rough, because of my broken english
You must be logged in to reply to this topic.
C74 RSS Feed | © Copyright Cycling '74