Link to home
Start Free TrialLog in
Avatar of summer_soccer
summer_soccer

asked on

cannot resolve class??

My code is like this:

Globals.java
--------------------------------------------------------------------------------
package topCan;

public interface Globals {
    int CARDINALITY = 2;      //cardinality of the CAN space
    int SIZE = 1000;          //number of total nodes in the CAN syste
    int LOWER_BOUND = 0;      //the lower coordinate boundary
    int UPPER_BOUND = 400;    //the upper coordinate boundary
    int NR_ALIVE_FOREVER = 6; // number of alive forever nodes that
                                     //bootstrap node keeps track of
}
--------------------------------------------------------------------------------------

Can.java
---------------------------------------------------------------------------------------
package topCan;

public class Can implements Globals {

    private int time_tick;        // the discrete timer
    private Bootstrap bstrap;     // the bootstrap node

   ................................................................
}
------------------------------------------------------------------------------------------

Bootstrap.java
-------------------------------------------------------------------------------------------
package topCan;

public class Bootstrap implements Globals {
    private int idCount;        // the counter of IDs that have been assigned
    // nodes indices ranging from 0 to NR_ALIVE_FOREVER-1 live forever

    public Bootstrap() {
      idCount = 0;              // id always starts from 1
    }
 
   ..............................................................  
 
}
-------------------------------------------------------------------------------------------------

All files are kept under the same directory. When I tried to compile Can.java, the first two errors I got were:

Can.java:9: cannot resolve symbol
symbol  : class Globals
location: class can.Can
public class Can implements Globals {
                            ^
Can.java:12: cannot resolve symbol
symbol  : class Bootstrap
location: class can.Can
    private Bootstrap bstrap;     // the bootstrap node
            ^

Anybody knows what's wrong here? thanx a lot.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Get into the directory above the topCan directory. Then do

java topCan\*.java
Then, if Bootstrap is going to be an application, run it with

java topCan.Bootstrap
>>java topCan\*.java

LOL. Should have been

javac topCan\*.java


Then, if Bootstrap is going to be an application, run it with

java topCan.Bootstrap
Avatar of summer_soccer
summer_soccer

ASKER

Why I should compile all of them? Doesn't the compilation of Can.java triggers compilations of rest classes in the same package if Can class uses them?
Can't remember - try it ;-)

The important point is, you have to be in the right directory and use the notations i mentioned for compiling and running
> Why I should compile all of them?

You don't need to.

> Doesn't the compilation of Can.java triggers compilations of rest
> classes in the same package if Can class uses them?

Yes it does (if a class file is not present, or out of date).
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>You don't need to.

Actually i seem to remember some older compilers (which some people are still using) not being able to make the compilation automatically like that.
?
Can you tell me why my answer did not solve your problem summer_soccer?
Hi CEHJ,

  I didn't mean your answer is not good. Actually I found out later by myself the reason why Can.java didn't trigger other classes it references is because there are some semantic errors in those classes, however, javac Can.java didn't prompt any error messages but simply ignoring those classes without compiling them.  After I fixed those semantic errors, javac Can.java caused every classes it uses being compiled.

Thanks for your reply.  :-)
It's just that the custom here that if two correct answers have been posted to select the first one, or possibly split the points, but certainly not to merely accept the second one.
Hey CEHJ,  I'm pretty new here. I'll remember next time. :-)