getting started with Max Java

Dg's icon

Hello,

I've discovered the classes folder in c74 > java and wonder I can find some patches with these?

Thank you

FRid's icon

Hi Kyred,

Those are located in c74 > java > help

Good luck,
FRid

Dg's icon

Thanks.
However I get no success trying to compile a very simple script with quickie.
Instead of opening my file.java quickie opens a default script.
Both the .java and the .maxpat are in the classes folder (attached).
Please help getting started!

3356.javasimplegridshape.java
java
Dg's icon

OK. Quickie just does like ".java" in the filename.
But now I get

Compiling /Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java.........

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/javac -classpath /Applications/Max6/Cycling '74/java/lib/ej.jar:/Applications/Max6/Cycling '74/java/lib/jitter.jar:/Applications/Max6/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar:/Applications/Max6/Cycling '74/java/lib/max.jar:/Applications/Max6/Cycling '74/java/classes/ /Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java

/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 9 ] expected
mycircle = new JitterObject("jit.gl.gridshape",new Atom[]{Atom.newAtom("cosm")});
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 11 ] expected
mycircle.setAttr("lighting_enable",1);
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 11 ] illegal start of type
mycircle.setAttr("lighting_enable",1);
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 11 ] illegal start of type
mycircle.setAttr("lighting_enable",1);
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 12 ] expected
mycircle.setAttr("smooth_shading",1);
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 12 ] illegal start of type
mycircle.setAttr("smooth_shading",1);
^
/Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java[ 12 ] illegal start of type
mycircle.setAttr("smooth_shading",1);
^
7 errors
[ 15 févr. 2012 18:37:55 ]
compilation of /Applications/Max6/Cycling '74/java/classes/javasimplegridshape.java failed.

Dg's icon

Okay, better like this and welcome to Java

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class javasimplegridshape extends MaxObject
{
JitterObject mycircle;

    public javasimplegridshape(Atom[] args)
    {

mycircle = new JitterObject("jit.gl.gridshape",new Atom[]{Atom.newAtom("cosm")});
// mycircle.setAttr("shape", "circle");
        mycircle.setAttr("lighting_enable",1);
        mycircle.setAttr("smooth_shading",1);
    }
}

FRid's icon

Since i'm also a java-noob i will/(mostly can) not go into detail about what you did wrong. This is too avoid the possibility to confuse you more. I did however add some comments though and if you just copy this layout you should be allright.

Max Patch
Copy patch and select New From Clipboard in Max.

HTH,
FRid

Dg's icon

Many thanks for these adds and comment, it really helps and the connexions with java theory come in my head.
:-)

FRid's icon

You're welcome and i'd love to help you with the other post too but i haven't yet played around with gl/jitter in java but i'm sure someone else will chime in.

Udo Matthias's icon

import com.cycling74.max.*;
could you please explain the line above in detail??
udo

hollyhook's icon

There is a actually a quite good documentation how to write java code for max. Search for WritingMaxExternalsInJava.pdf in the installation folder. It says:

/* import the supporting classes from the max.jar API so you
can refer to them without the full package justification. */
import com.cycling74.max.*;