aspose file tools
The moose likes Beginning Java and the fly likes Compiler Error: cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Storm Applied this week in the Other Open Source APIs forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiler Error: cannot find symbol" Watch "Compiler Error: cannot find symbol" New topic

Compiler Error: cannot find symbol

Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
Hey all, Thanks in advance for your help. I'm a Java newbie and am having trouble compiling this program. Here's what I have so far:

2 Classes:
1. (main class)
2. (instantiable class)

Path Variable:

C:\Program Files\Java\jdk1.5.0_06\bin


class Customer {
private String customerID;
private String firstName;
private String lastName;
private String address;
private String emailAddress;
private int age;
private boolean hasCollegeEd;
private double gradePointAverage;
private boolean accidentStatus;
private double surcharge;

public Customer(String c_id, String f_name, String l_name, String add, String email, int a, boolean col_ed, double gpa, boolean a_status) {
customerID = c_id;
firstName = f_name;
lastName = l_name;
address = add;
emailAddress = email;
age = a;
hasCollegeEd = col_ed;
gradePointAverage = gpa;
accidentStatus = a_status;


public double calculateSurcharge(int a, boolean a_status, boolean c_ed, double gpa) {

return surcharge;

public void display() {
System.out.println("**** ABC Insurance Co. ****");
System.out.println("Customer ID: " + customerID);
System.out.println("Surcharge: %" + surcharge);




class Test {
public static void main(String[] args) {
Customer cust1 = new Customer("235678", "John", "Doe", "1313 Mockingbird Ln", "email address", 20, false, 0.0, true);
cust1.calculateSurcharge(20, true, false, 0.0);


When I go and compile this at the command line: javac *.java (inside of my directory) I receive this error: cannot find symbol
symbol : constructor Customer(java.lang.String, java.lang.String, java.lang.String, java.lan.String, java.lang.String, int, boolean, double, boolean)
location class: Customer
Customer cust1 = new Customer("1234","John","Doe", "1313 Mockingbird Ln.", "email address", 20, false, 0.0, true);

1 error


It looks like it's complaining about my constructor method, but I've checked to make sure that the arguments match the parameters in type. I'm lost, my guess is that it has something to do with my path variable.

Please help!!

Thanks again
[ February 01, 2006: Message edited by: Brian LaRue ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

Hi Brian,

Welcome to JavaRanch!

Sometimes you can get yourself into a state where your .class files come from an older version of your source, but have newer timestamps than the source; the compiler will then look at the old/new class files and not the source code, and you'll get an error like this that doesn't make sense based on the source.

Carefully delete every "Customer.class" you can find -- you might have some hiding in strange places, so look carefully -- and then try compiling again.

[Jess in Action][AskingGoodQuestions]
Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
Whoa! That did it, interesting. I would have never guessed to try that, Thanks!
[ February 01, 2006: Message edited by: Brian LaRue ]
Mamoun Jamous

Joined: Jul 01, 2010
Posts: 3
Hi everybody
Well, I've tried the magical solution you have stated but It didn't work for me.
It's true that I'm new to Java as well, so I know that my problem is a silly one.

My files are located in the following architecture, and they are copied right from a book.
there is two files in there, the first is and the other is
compiling the first one would produce no problems, but since the second one is an implementation of the first, i get the following error when I try to compile it:


C:\jws\ch01\ts>javac cannot find symbol
symbol: class TimeServer
public class TimeServerImpl implements TimeServer {
1 error


the first file code is:

the second file is:

thanks in advance for taking some time to review this.
Mamoun Jamous

Joined: Jul 01, 2010
Posts: 3
I've managed to compile the file, and here is how:
1. I deleted the compiled file of the first file "TimeServer.class"
2. I closed the prompt window and opened a new one and typed:
c:\> javac jws/ch01/ts/*.java

I have no idea why it worked this way, but it does.
I would feel very happy to hear an explanation

wish you all a nice day.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You need to compile your code from C:\jws - and then use the package in front of the Class name

Like this:

C:\jws>javac ch01/ts/
C:\jws>javac ch01/ts/

and then when you want to call the Class, do it from the same folder - and again starting with package.

Regards, Rene Larsen
Dropbox Invite
Mamoun Jamous

Joined: Jul 01, 2010
Posts: 3
I've tried to do what you have mentioned, but it didn't work!

I've tried to compile a new file named, which is located at the same folder
I tried:
c:\jws> javac ch01/ts/
the error message I had is exactly the same.

I deleted all .class files, then tried again the following:
c:\javac jws/ch01/ts/*.java

and it worked perfectly for the 3 files.

is it possible that I have to compile all the files from the same location "like i've done it from c:\ for the first two yesterday, so i have to do it from the same location today for the 3rd file"? I'll try and comment later.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 42020
Josh Bilger,
Your post was moved to a new topic.
I agree. Here's the link:
subject: Compiler Error: cannot find symbol