Cannot load classes that are not in my "(default package)" in Eclipse

    Apr 29 2010 | 9:47 pm
    Hi, i spent few years with mxj, having my unique "/2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin" folder in the file "", max loading my classes without problems.
    The problem is that I wanted to have others folders, to put my classes, because i want to organize them more clearly.
    So, in Eclipse, I tried to make a new project (called "testsClasses") / and i tried also to make a new package (called "test2") in my original project ...
    then I put theses new Eclipse folders in "" too, like this :
    max.dynamic.class.dir /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin (this one was already here) max.dynamic.class.dir /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin/test2 max.dynamic.class.dir /2-Erdna/eclipse/MyWorkspace/testsClasses/bin
    ...But it doesn't works, i cannot load the classes that are my new folders in max...
    I get some error messages in the max window : (see picture)
    I really don't understand what's happening. i've redone the max/eclipse tutorial from Adam, i think i didn't miss anything. maybe a problem in "". Isn't it possible to have more than one folder for mxj classes ?
    Please help! Thanks!

    • Apr 30 2010 | 1:45 pm
      Yes it should work. I think the problems may lay in your files. Could you post the code please (and complete file path)?
    • Apr 30 2010 | 3:10 pm
      Ok, after many tries of changing "" and restarting max without success, it finally worked for the classes in my NEW PROJECT after i restarted the macbookpro, hmm... But for my NEW PACKAGE, it still doesn't work...
      max window always say the same :
      "java.lang.NoClassDefFoundError: nothing2 (wrong name: test2/nothing2) ... ... "
      (the class ''nothing2'' is also in my new package called ''test2'' in my ''MyMxjClasses'' project)
      it's just a simple class doing nothing, here is the code:
      package test2; import com.cycling74.max.*; public class nothing2 extends MaxObject { nothing2 (Atom[] a) { declareInlets(new int[]{ DataTypes.ALL }); declareOutlets(new int[]{ DataTypes.ALL, DataTypes.ALL }); createInfoOutlet(false); post("INIT"); } public void bang() { outlet(0, "BANG RECEIVED"); } }
      ...where the line "package test2;" was automaticaly added by Eclipse (and if i suppress it, it doesn't compile)
      Of course, the class loads perfectly when i put it in one of the other folders. It looks like i can't load any class that is inside a package inside a project.
      Thanks again for any help, Alexandre
    • Apr 30 2010 | 8:38 pm
      Java class files must live in a directory structure identical to their package name. The classpath should points to the root of that directory structure, not to a package subdirectory.
      For example, a if you create a class declared like this:
      package my.tests;
      public class Test1 extends com.cycling74.max.MaxObject {
      it must be put it in the file ...src/my/tests/Test1.class.
      In this case, eclipse will compile it and write the class file to ...bin/my/tests/Test1.class.
      You should then set your classpath to ...bin, because that directory contains the root of the package hierarchy.
      Is this clear?
    • May 01 2010 | 12:39 pm
      it doesn't work. Eclispe put all the classes in their right places as you say, i think.
      >>You should then set your classpath to ...bin, because that directory contains the root of the package hierarchy.
      If i understand well what you explain, as i have some classes in my default package, which are in: /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin, and also have some classes in the test2 package, which are in: /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin/test2, i should then only put : max.dynamic.class.dir /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin in ?
      then max could find what is in /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin plus what is in /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin/test2
      But this doesn't work. max doesn't find the classes in /test2, it just says : "Could not load class 'nothing2'". max can only find the classes from the default package of a project.
      And, as i said above, when i add : max.dynamic.class.dir /2-Erdna/eclipse/MyWorkspace/MyMxjClasses/bin/test2 in, i then get even more error messages :
      java.lang.NoClassDefFoundError: nothing2 (wrong name: test2/nothing2) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass( at com.cycling74.max.MXJClassLoaderImpl.doLoadClass( at com.cycling74.max.MXJClassLoader.loadClazz( Could not load class 'nothing2'
      Should i send a message to cycling74 to ask them ? Thanks,
    • May 01 2010 | 1:41 pm
      oohhhh, Sorry!
      i just realised that i add to put [mxj test2.nothing2] instead of [mxj nothing2] so stupid...
      WORKING NOW...
      (true i'm not a java expert.)