Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Netbeans can't see classes in the same directory

Posted on 2004-03-28
7
Medium Priority
?
328 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

916 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