Solved

Netbeans can't see classes in the same directory

Posted on 2004-03-28
7
324 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
Revamp Your Training Process

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

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jboss wildfly 10.1 10 613
How to convert from xls to xlsx using java 7 158
maximize the sum of fractions 33 75
Pass multiple values or string arrays in java as a parameter 3 73
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

734 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