Solved

Netbeans can't see classes in the same directory

Posted on 2004-03-28
7
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

628 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