Please help debuging my JS to java


    Feb 20 2012 | 5:05 pm
    This results in a bunch of error, help me on what I should do. files attached.
    Extract:
    1) noiserInitLoc = new JitterObject("jit.noise"); noiserInitLoc.setAttr("dim", [60, 60]); noiserInitLoc.setAttr("planecount", 2); noiserInitLoc.setAttr("type", "float32");
    2) public void getxfade(int v) { XYfadeobj.setAttr("xfade", v); }
    3)
    public void matrix(String s) { smallXYmtrx.setAttr("name", s); }
    4)
    public void bang() { { STmtrx.frommatrix(smallSTmtrx);//output texcoords }
    { XYphysics()//output physics //outlet(1, "jit_matrix", XYphysmtrx.name); }
    { XYmtrx.frommatrix(smallXYmtrx);//output XY }
    { xfade();//mix XY & XYphysics }
    { packfive(); } }
    4) packerobj = new JitterObject("jit.pack"); packerobj.setAttr("jump",[2, 1, 2]);

    • Feb 21 2012 | 10:19 am
      Java belongs - unlike JS - to the family of strongly typed languages. This means among others that variable types have to be defined on initiation, and that functions have a fixed signature, that will only accept one combination of variable types.
      an then you have bunch of typos in there and some functions are not formated properly.
      j
    • Feb 21 2012 | 2:33 pm
      Okay, thanks for your answer but it doesn't help much. I know that Java uses types, classes & methods, accessors, constructors, inheritance and so on ... I know that I have to study the theory and it is what I am currently doing with passion. But I'm also sure that Java - for what I'm trying to do - here - can be simple et accessible for a beginner (I'm not a beginner in Max or Jitter). The lines above have been extracted from a bigger code that is attached, with its equivalent in JS and equivalent in Max (both free of bug) and I'm sure it would take a couple a minutes for anyone who daily uses java to give me some elements that would help to go ahead in practice. At this stage, get stuck in books, reference and tutorial will not help very much. I know that it is not a good idea to give the result of the console in this forum, but it is clear that the error I get are silly. For example, how should I specify a list of int in order to indicate the values for a [jit.pack 5 @jump 2 1 2] class. Is Atom[] the way to do that and how to use it? Same question if I want to change dynamically the dimension of a matrix. I do not ask about how to do my classes, my constructor etc. This is my busyness, ok. Please help go further.
      Compiling /Applications/Max6/Cycling '74/java/classes/xyzmove_00.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/xyzmove_00.java
      /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] illegal start of expression packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] ';' expected packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] illegal start of expression packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] ';' expected packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] illegal start of expression packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] ';' expected packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] illegal start of expression packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 84 ] ';' expected packerobj.setAttr("jump",[2, 1, 2]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] illegal start of expression noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] ';' expected noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] illegal start of expression noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] ';' expected noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] illegal start of expression noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 92 ] ';' expected noiserInitLoc.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] illegal start of expression noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] ';' expected noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] illegal start of expression noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] ';' expected noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] illegal start of expression noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 99 ] ';' expected noiserInitVel.setAttr("dim", [60, 60]); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 115 ] ';' expected init() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 119 ] invalid method declaration; return type required public init() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 140 ] class, interface, or enum expected public void getxfade(int v) ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 143 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 146 ] class, interface, or enum expected public void matrix(String s) ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 149 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 152 ] class, interface, or enum expected public void matrix_matrix(String s); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 153 ] class, interface, or enum expected { ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 155 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 159 ] class, interface, or enum expected public void XYphysics() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 165 ] class, interface, or enum expected mtrx.op("*", mtrx, 0.999); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 168 ] class, interface, or enum expected XYphysmtrx.frommatrix(mtrx); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 171 ] class, interface, or enum expected XYphysmtrx.op("+", XYphysmtrx, tempmtrx); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 174 ] class, interface, or enum expected XYphysmtrx.op("fold", XYphysmtrx, 1.); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 177 ] class, interface, or enum expected XYphysmtrx.op("*", 5.0); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 178 ] class, interface, or enum expected XYphysmtrx.op("-", 2.5); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 179 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 186 ] class, interface, or enum expected public void xfade() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 189 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 193 ] class, interface, or enum expected public void packfive() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 196 ] class, interface, or enum expected outlet(0, "jit_matrix", XYZSTmtrx.getName()); ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 197 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 202 ] class, interface, or enum expected public void bang() ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 206 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 215 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 219 ] class, interface, or enum expected } ^ /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java[ 223 ] class, interface, or enum expected } ^ 47 errors [ 21 févr. 2012 15:18:17 ] compilation of /Applications/Max6/Cycling '74/java/classes/xyzmove_00.java failed.
    • Feb 21 2012 | 5:13 pm
      Atom description here: file:///Applications/Max6/java-doc/tutorial/html/Tutorial05.html
      Reference there file:///Applications/Max6/java-doc/api/index.html
      Please help me debugging other things from the console.
    • Feb 21 2012 | 5:19 pm
      And Yes, Jan, Oracle tutorial seems well done.
    • Feb 21 2012 | 6:04 pm
      :) I think he knows the atoms and api well enough. Having been there a couple of days ago myself i can imagine how you feel though, coding can be a pain sometimes especially because the answer is somewhat in front of you. Instead of debugging i would recommend starting from scratch again, this way you will avoid typo's and you probably have a better understanding of where it goes wrong. Plus debugging 47 error's?
      I'll be out for a couple of hours but after that i'll (try*) to take a look. Untill then good luck and be patient. FRid
      *try: never used objects inside of mxj before so this is new for me too (or jitter).
      Also if you are not already using a real ide to write the code in i'd suggest to get one such as eclipse or netbeans. For example i use netbeans and if i write something wrong, wether it is a typo or a wrong method it will highlight the line with the error immediately.
    • Feb 21 2012 | 9:18 pm
      I am tonight at Lyon open Lab, the Lyon's hackerspace and people here are great. Don't really know if I'll achieve a big step but it really helps. Someone posted this link on Max in Eclipse: http://compusition.com/web/articles/maxmsp-eclipse - probably a good start for IDE ... for me
    • Feb 21 2012 | 9:26 pm
      34 errors, better!
    • Feb 21 2012 | 10:56 pm
      Hi Kyred,
      Working with eclipse will be a good thing, as it will give you very detailed information on bug. And what is even better: it will make suggestions for possible bugfixes.
      j.
    • Feb 22 2012 | 12:00 am
      Well, back again and i've managed to get it down to 18 error's, those are mostly the "setAttr"-messages and now i remember why i was/am reluctant to work with maxobjects inside of java, because of the somewhat illogical way the api works. For example it's instantiating an object such as that always seem to give me a hard time:
      noiserInitVel = new JitterObject("jit.noise"); noiserInitVel.setAttr("dim", 60, 60); noiserInitVel.setAttr("planecount", 2); noiserInitVel.setAttr("type", "float32");
      Why not just as in max type the name and all arguments in one line something like this, much cleaner and intuitive to max-users;
      noiserInitVel = new JitterObject("jit.noise", 2, "float32", 60, 60");
      Like i said i'm not into the objects so you're on your own there.
      Good luck, FRid
    • Feb 22 2012 | 12:16 am
      @Jan Yes thx! indeed, someone here give some help on Eclipse. Nice to see rect bubbles giving you info on JitterObject and things.
      @FRid Yes, it is the way for all jitter object except the matrix for which you type one line. Same behavior in Javascript (but works well, attached above). Well! 18 error's? any chance to have a look? You can use the Message this user feature if you want oh! so-cial net-work!
      Also I'd like to pass Atoms a list of arguments and set the dimension of the matrix with. I'd do ... public void dim(int a, int b) { jm.setAttr("dim", a, b); }