MXJ and XCode


    May 11 2006 | 7:58 pm
    Hello,
    I've been using XCode to compile Java classes for MaxMSP. In order to compile classes successfully, I found it necessary to place copies of the Max .jar files in /Library/Java/Extensions.
    As long as the files in Extensions are current, there are no problems with either Max or XCode. Forgetting that I had a stale .jar file in Extensions led to some strange errors and eventually to serious crashes on starting up Max. So, I'm looking for better ways of getting XCode to compile mxj classes.
    Symbolic links or aliases to the .jar files don't seem to work for XCode. Really it should all be possible by setting the classpath.
    In the Terminal, this works:
    [Tomillo:~/Developer/Test2] paulhz% javac -classpath .:/Library/Application Support/Cycling '74/java/lib/max.jar:/Library/Application Support/Cycling '74/java/lib/jitter.jar:/Library/Application Support/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar:/Library/Applicati on Support/Cycling '74/java/classes/Plus2.java Plus2.java
    In XCode I set the JAVA_COMPILER_FLAGS for all Targets to -classpath .:/Library/Application Support/Cycling '74/java/lib/max.jar:/Library/Application Support/Cycling '74/java/lib/jitter.jar:/Library/Application Support/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar:/Library/Applicati on Support/Cycling '74/java/classes/
    And for good measure, I set the Project Info Build property LIBRARY_SEARCH_PATHS = "/Library/Application Support/Cycling '74/java/lib/max.jar /Library/Application Support/Cycling '74/java/lib/jitter.jar /Library/Application Support/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar /Library/Application Support/Cycling '74/java/classes/Plus2.java Plus2.java"
    In Xcode I get this error:
    frameworkjars="" for i in echo ; do if [ -f "$i" ] ; then frameworkjars="$frameworkjars":"$i" ; fi ; done
    classpath="/Users/paulhz/Developer/Test2/build/Test2.build/D evelopment/Test2.build/JavaClasses:/Library/Application Support/Cycling '74/java/lib:/Library/Application Support/Cycling '74/java/classes$frameworkjars:"/usr/bin/javaconfig DefaultClasspath /usr/bin/javac -J-Xms64m -J-XX:NewSize=4M -J-Dfile.encoding=UTF8 -deprecation -classpath .:/Library/Application Support/Cycling '74/java/lib/max.jar:/Library/Application Support/Cycling '74/java/lib/jitter.jar:/Library/Application Support/Cycling '74/java/lib/jode-1.1.2-pre-embedded.jar:/Library/Applicatio n Support/Cycling '74/java/classes/ -g -encoding MACINTOSH -sourcepath /Users/paulhz/Developer/Test2/. -classpath "$classpath" -d "/Users/paulhz/Developer/Test2/build/Test2.build/Development /Test2.build/JavaClasses" '@/Users/paulhz/Developer/Test2/build/Test2.build/Developmen t/Test2.build/JavaFileList' javac: invalid flag: Support/Cycling Usage: javac /.../
    So, it looks as though XCode is mangling my classpath, removing the " " and "'" escape codes. Go figure.
    Has anyone dealt with this situation before, or successfully compiled mxj classes in XCode without dropping the .jars into the Extensions folder?
    -- Paul
    -- ----- |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| -----

    • May 11 2006 | 9:00 pm
      Hey Paul, I just threw this sample xcode project together. If it doesn't solve your problem it should definitely put you in the right direction.
      I took the default java tool xcode project. changed output type from jar archive to class hierarchy added max.jar to the project via Project->add to target... added a shell script build phase which copies all class files in the built products directory to C74/java/classes
      sometimes xcode gets out of sync an barfs. this is a problem in general. if something really weird is going on it is worth while to quit and than build clean upon startup.
      this just worked for me though. i never got around to doing this before. i always use quickie. good to know about xcode. thanks.
      topher
    • May 11 2006 | 10:45 pm
      Hi Paul,
      Given the variety of issues that people have encountered with xcode, you may want to investigate the Eclipse IDE if you haven't already. I can't recommend it highly enough!
      Ben
    • May 12 2006 | 8:54 am
      Agreed; it takes a bit of effort to set up projects neatly, but once running, it rocks. (It's worth it for the integrated CVS support alone...) Oh, and it's multi-platform.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • May 12 2006 | 3:29 pm
      I have tried Eclipse, and guess I have something of a on again/off again relationship with it. The proliferation of windows is worse than XCode, though there are features I have really liked.
      Anyhow, adding the .jar files to the project as Topher suggested works--though ISTR that I tried that before and did not get things to work.
      Once I do that it appears that no classpath information is required, not even in the Target Search Paths, which get bundled together into a shell variable and passed to javac.
      thanks,
      -- Paul
    • May 12 2006 | 3:49 pm
      I have been studing the list classes and decided to add one of my own. delta computes the differences between values in a list. My runsum does the opposite taking a list of deltas and returning the running sum. Musically speaking, deltas are durations and the result of runsum is a set of attack points.
      At the moment I am trying to set the [0] element of the b list to zero. Eventually I plan to use a second inlet to set the starting value. The compiler (quickie) is telling me that it expects a ")" in the line that begin b[0]. What am I doing wrong?
      package list; import com.cycling74.max.*;
      /** * given an input list of length N, * outputs a list of length N-1 * whose elements represent * the difference between successive elements * in the input list. * * @author bbn * created 2004.05.03 */ public class runsum extends ListProcessor {
      runsum() { declareIO(1,1); }
      public void input(int idx, Atom[] a) { int len = a.length + 1; Atom[] b = new Atom[len]; b[0] = Atom.newAtom(0.toFloat()); for (int i=1;i b[i] = Atom.newAtom(a[i-1].toFloat()+b[i].toFloat()); setOutput(0, b); }
      }
      Cheers, Gary Lee Nelson TIMARA Department Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • May 12 2006 | 4:03 pm
      On 12 May 2006, at 16:29, Paul Hertz wrote:
      > The proliferation of windows is worse than > XCode, though there are features I have really liked.
      The whole view/perspective thing can be a bit much, but it's pretty easy to customise it to show what's important and not show what's not.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • May 12 2006 | 4:06 pm
      On 12 May 2006, at 16:49, Gary Lee Nelson wrote:
      > The > compiler (quickie) is telling me that it expects a ")" in the line > that > begin b[0]. What am I doing wrong?
      0 isn't an object (in Java, not everything is an object) so you can't call methods on it. (And isn't toFloat() an Atom method anyway?)
      As I recall, ints are automatically promoted to floats.
      -- N.
      nick rothwell -- composition, systems, performance -- http:// www.cassiel.com
    • May 12 2006 | 5:05 pm
      I am trying to set the first element of the array b to zero. Simply
      B[0] = 0.0;
      Doesn't work.
      Cheers, Gary Lee Nelson TIMARA Department Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • May 12 2006 | 5:11 pm
      What error are you getting?? It's hard to know what's going on when your description "it doesn't work" is so vague. If it doesn't work, there's usually some kind of feedback from the compiler that is more specific if obscure. If I remember corectly, Java doesn't like assigning 0.0 to floats because it thinks it's losing precision. Try 0.f.
      best, wes
    • May 12 2006 | 5:12 pm
      > b[0] = Atom.newAtom(0.0f);
      should work.
    • May 12 2006 | 5:14 pm
      > > Once I do that it appears that no classpath information is required, > not even in the Target Search Paths, which get bundled together into a > shell variable and passed to javac. >
      if you look it appears in the link library build phase of the target executable. topher
    • May 12 2006 | 5:14 pm
      Hi,
      b[0] = Atom.newAtom(0);
      should work.
      By the way, if you're only dealing with float/int, it will be more efficient to use the list(float[] arg) method instead of list(Atom[] args).
      Best, ej
    • May 12 2006 | 6:05 pm
      Yes, that got it and I was able to add a variable starting value with a declared attribute. It's bloody marvelous!
      Cheers, Gary Lee Nelson TIMARA Department Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • May 13 2006 | 11:48 am
      On 5/12/06 1:13 PM, "topher lafata" wrote:
      >> b[0] = Atom.newAtom(0.0f); > > should work.
      Yes it did. Thanks Topher. BTW, your manual for this is very helpful. Cheers, Gary Lee Nelson TIMARA Department Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • May 13 2006 | 12:03 pm
      Actually, I was using the list processor externals as models and the "runsum" external I wanted to make added something to that set. I think I summarized it in another message. And also, I like the idea of mixed data types. Try using list.Permute on a line of poetry.
      Cheers, Gary Lee Nelson TIMARA Department Oberlin College www.timara.oberlin.edu/GaryLeeNelson