multiple class, package, or .jar examples

vodstrup's icon

Hi,

I've been spending some time with the mxj tutorial and looking at many
of the java examples, but I was wondering if there were any examples
of using multiple classes, package, or .jar files within Max? I
didn't see any, but I might have overlooked something. Tutorial09
leaves me wanting a bit more...

I have a program that I have cobbled together in Java (still very noob
to Java) and now I am trying to convert it into a Max object in order
to use the data it collected within Max. My Java program uses a
couple of libraries and many external class files. The beginning of
my main class designates a package.

It's all very messy right now and I'm trying to simplify...

thanks in advance...

(also is this the right list to post to - it's a "dev" list?)

Bart

Owen Green's icon

Hi Bart,

Yes, this is the right list.

It's not entirely clear what you're after here, but I'll try and shed
some light.

The process for using other code in an mxj object is the same as in Java
generally: import [whatever]. You do, however, need to make sure the
classes in question are on mxj's classpath.

If you're converting a vanilla app to an mxj object, instead of having a
main class that declares public static void main(String arg[]), you have
a class that descends from MaxObject that provides an interface for
communication with objects in your patcher. This also needs to be on the
classpath.

If you can be more specific, so can I :)

--
Owen

bart woodstrup wrote:
> Hi,
>
> I've been spending some time with the mxj tutorial and looking at many
> of the java examples, but I was wondering if there were any examples
> of using multiple classes, package, or .jar files within Max? I
> didn't see any, but I might have overlooked something. Tutorial09
> leaves me wanting a bit more...
>
> I have a program that I have cobbled together in Java (still very noob
> to Java) and now I am trying to convert it into a Max object in order
> to use the data it collected within Max. My Java program uses a
> couple of libraries and many external class files. The beginning of
> my main class designates a package.
>
> It's all very messy right now and I'm trying to simplify...
>
> thanks in advance...
>
> (also is this the right list to post to - it's a "dev" list?)
>
> Bart
>

vodstrup's icon

Thanks for replying Owen. I've been getting some help off the list
from a Java pro. We got it working, but I may be having some thread
and timing questions in the near future.

thx,

Bart

On 8/7/07, Owen Green wrote:
> Hi Bart,
>
> Yes, this is the right list.
>
> It's not entirely clear what you're after here, but I'll try and shed
> some light.
>
> The process for using other code in an mxj object is the same as in Java
> generally: import [whatever]. You do, however, need to make sure the
> classes in question are on mxj's classpath.
>
> If you're converting a vanilla app to an mxj object, instead of having a
> main class that declares public static void main(String arg[]), you have
> a class that descends from MaxObject that provides an interface for
> communication with objects in your patcher. This also needs to be on the
> classpath.
>
> If you can be more specific, so can I :)
>
> --
> Owen
>
>
> bart woodstrup wrote:
> > Hi,
> >
> > I've been spending some time with the mxj tutorial and looking at many
> > of the java examples, but I was wondering if there were any examples
> > of using multiple classes, package, or .jar files within Max? I
> > didn't see any, but I might have overlooked something. Tutorial09
> > leaves me wanting a bit more...
> >
> > I have a program that I have cobbled together in Java (still very noob
> > to Java) and now I am trying to convert it into a Max object in order
> > to use the data it collected within Max. My Java program uses a
> > couple of libraries and many external class files. The beginning of
> > my main class designates a package.
> >
> > It's all very messy right now and I'm trying to simplify...
> >
> > thanks in advance...
> >
> > (also is this the right list to post to - it's a "dev" list?)
> >
> > Bart
> >
>
>

--

bartwoodstrup.com
vodstrup.com

Mattijs's icon

vodstrup wrote on Sun, 12 August 2007 04:43Thanks for replying Owen. I've been getting some help off the list
from a Java pro. We got it working, but I may be having some thread
and timing questions in the near future.

thx,

Bart

Hi Bart,

The only way I got this to work is to put both classes in a named package and import the external class into the class of the max object explicitly. So somehow Max doesn't search for class definitions inside the default package.

If you (or someone else) knows of an easier way, I'd love to know.

Best,
Mattijs

Hans Höglund's icon

Quote:
So somehow Max doesn't search for class definitions inside the default package

For a good reason. A max patch can contain several mxj/mxj~ objects, each loading classes from different projects or developers, all using the same JVM instance.

The default package is always evil. Personally I think it should be avoided in mxj alltogether, except maybe for the max entry-points (MaxObject descendants).