Java in max (the 'easy' way)

anamaria's icon

Hi,

I tried to go through the java tutorials, but I have a problem - I can't get the java code to compile.

I am new to java, but have been working with processing before, so java seems familiar to me.

If I just could open up some java code in the max patch itself by double clicking a max/java object, then I am sure that I can go on from there, so all I am asking for is if anyone has some example code for max with a java object in the max patch with one inlet and one outlet defined in the java code.

In this way I can click on the max/java object, open up the code and add onto the code from within max.

Thanks ahead,

ana

Luke Hall's icon

Try compiling it with [mxj quickie yourobjname] which should set everything up for you in a max editor window. You can compile from there and should have no problems.

lh

efe's icon

hello anamaria:
Ok, different issues:
1-There are different ways to compile java externals: you can use the quickie, the java compiler in the terminal or an IDE(Eclipse, NetBeans or XCode). If you decide to go with the terminal your will need to type something similar to this:
javac -classpath /Applications/Max5/Cycling '74/java/lib/max.jar:/Applications/Max5/Cycling '74/java/lib/jitter.jar AnaMaria.java

2-Yes, processing is Java but it has subtle differences with the java- jitter implementation. If you open the Processing sources you will discover that it is using something called PApplet:

Jitter makes use of matrices, take a look into the jitter tutorials. That means that you will need to translate the methods from processing into something that can be used as matrix information. In the example attached i am using a simple random generator which fills with values the coordinates(i,j) of the matrix jjm .

3-I strongly suggest you to study the API, there you will find all kind of useful information.

good luck!
Emmanuel

792.template.zip
zip
Charlie Williams's icon

Thanks! That template goes a long way toward explaining the confusing bits of "where's my code inside of mxj?"

efe's icon

Hehehe, hope it is useful!