Solved

Netbeans can't see classes in the same directory

Posted on 2004-03-28
7
317 Views
Last Modified: 2012-06-21
Hi,
I'm using netbeans to edit some java code and netbeans is having a hard time seeing classes that are in the same directory. My code is pasted below.
One example that netbeans can't see is the Server class. As you can see in my code I have a line like "  private Server wash_machine;". Although I certainly have the necessary Server class in the same directory netbeans gives the following error:
"mscarwash/Car.java [12:1] cannot resolve symbol
symbol  : class Server
location: class Car
  private Server wash_machine; "

Any help is appreciated...



My code:

import psimjava.*;
public class Car extends psimjava.Process
{
  private Server wash_machine;   // ref to server object
  private int customerNum;       // customer number
  private double arrivalTime;    // arrival time of customer
  private double service_dur;    // customer service service_dur
  public Car(String name, double dur)
  {
    super(name);
    customerNum = Carwash.num_arrived;
    arrivalTime = get_clock();
    service_dur = dur;
  }
  //
  public double get_arrivalT()
  {
    return arrivalTime;
  }
  public double get_serv_dur()
  {
    return service_dur;
  }
  public void Main_body()
  {
    if (! Carwash.car_queue.full())   // if queue is not full
    {
      Carwash.out.println(get_name() +
      //      " requiring service " + service_dur +
              " joins queue at time " + get_clock());
      // if server queue non-empty, dequeue server
      if (Carwash.server_queue.empty() == false)
      {
        wash_machine = (Server) Carwash.server_queue.out();
        Carwash.out.println("Activating " + wash_machine.get_name()
            + " at time " + get_clock());
        reactivate(wash_machine);// reactivate server
      }
      Carwash.car_queue.into(this);      //enqueue this process
      deactivate(this);    // suspend itself to wait for service
      // service completed, do final computation
      Carwash.num_serviced++;            // customers serviced
      //total time in the system: custSojournTime
      Carwash.custSojournTime += get_clock() - arrivalTime;
      Carwash.out.println(get_name() + " terminates at " +
          get_clock());
      terminate();      //terminates itself
    }
    else                               // queue full, abandon hope
    {
      Carwash.num_rejected++;
      Carwash.out.println(get_name() + " rejected, queue full ");
      terminate();                     // terminate this object
    }
  }
}
0
Comment
Question by:halukakin
  • 3
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10700583
is Server class in a package?
0
 

Author Comment

by:halukakin
ID: 10700619
Here is the Server class...



import psimjava.*;

public class Server extends psimjava.Process
{
  private Car currentCustomer;    // customer currently being serviced
  public Server(String name)
  {
    super(name);
    Carwash.out.println(name + " created at: " + get_clock());
  }
  public void Main_body()
  {
    double startIdle;
    double idle_period;               // idle period
    while(get_clock() < Carwash.simPeriod)
    {
      if(Carwash.car_queue.empty())
      {
          startIdle = get_clock();    // starting of idle period
          // queue is empty
          Carwash.out.println(get_name() + " goes idle at " +
              get_clock());
          Carwash.server_queue.into(this); // join server queue
          deactivate (this);               // suspend server
          // queue must now be nonempty
          idle_period = get_clock() - startIdle;
          Carwash.accum_idle += idle_period;
          Carwash.out.println(get_name() + " reactivated at " +
              get_clock());
      }
      serviceCustomer();             // service the car
    }
  }
  private void serviceCustomer()
  {
    double startTime;       // time of start of service
    double service_per;     // service period for car object
    startTime = get_clock();        // service start time
    // get customer from head of waiting queue
    currentCustomer = (Car) Carwash.car_queue.out(); // dequeue
    Carwash.out.println(currentCustomer.get_name() +
        " begins at: " + startTime +
        " service " + currentCustomer.get_serv_dur() );
    // accumulate waiting time for this customer
    Carwash.custWaitTime += startTime - currentCustomer.get_arrivalT();
    service_per = currentCustomer.get_serv_dur();
    delay(service_per);
    // accum service time
    Carwash.custServiceTime += get_clock() - startTime;
    reactivate(currentCustomer);   // let car continue
  }
}  // end of Server class
0
 
LVL 92

Expert Comment

by:objects
ID: 10700717
does the Server class compile?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

by:objects
ID: 10700719
the obvious thing to try would be to add the directory that contains Car.java to the classpath used by NetBeans
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10701983
If your directory where both classes Car & Server are in is called e.g. test
then add as the first line in your codes:

package test;

0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 10701985
is your directory called 'mscarwash'?

Well, then add in both Car & Server (and others) as first line:

package mscarwash;

0
 
LVL 37

Expert Comment

by:zzynx
ID: 10789543
Thanks for accepting.
That keeps us answering questions in the future too.
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Eclipse IDE - Cannot copy/paste from console output 8 132
eclipse java  build path 6 45
Java Timer (static) 9 36
xampp tool 12 28
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now