Solved

Netbeans can't see classes in the same directory

Posted on 2004-03-28
7
315 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
Comment Utility
is Server class in a package?
0
 

Author Comment

by:halukakin
Comment Utility
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
Comment Utility
does the Server class compile?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for accepting.
That keeps us answering questions in the future too.
:)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

771 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

10 Experts available now in Live!

Get 1:1 Help Now