2 Replies Latest reply: Sep 28, 2010 2:28 PM by 801348 RSS

    Cannot find symbol error when compiling in different packages

    801348
      Hey all,

      I'm trying to divide my project into a sensible hierarchy. This is what I want:
      MyProject
      MyProject/src ................................. where all the source files are (no further directories)
      MyProject/classes
      MyProject/classes/Main.class
      MyProject/classes/classes2 ................ sorry for not being creative XD
      MyProject/classes/classes2/Age.class
      Now, Age uses Main, and this is where the trouble is. I'm using javac directly to compile Age, and this is how I'm doing it:
      //from MyProject
      javac -cp classes src/Age.java
      And I get this error:
      bla bla bla...cannot find symbol
      symbol  : variable Main
      location: class classes2.Age
                years = (byte)(Main.year - m.getYear());
                               ^
      Main is already compiled and in place.

      Also, this is how Age.java starts:
      package classes2;
      
      public class Age
      {...etc
      I'm using JCreator as an IDE (and using it's own build function, the same error occurs, which is why I tried directly compiling the file).

      Why can't javac find Main.class? I tried searching Google, but my particular problem didn't seem to crop up.

      Hope I provided enough information, and ask if more is needed.

      Many thanks :)