compile javac help needed for beginner. apparently it doesnot understand the word extends?????

G

George Kooper

I have installed Java from Sun site to my Windows XP .

I have modified the PATH statement to include:
C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program
Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft
VisualStudio\VC98\bin;C:\j2sdk1.4.2_03\bin;


I have 2 files in my directory:
Person.class:
class Person {
String name;
int age;
}

and
Customer.java:
class Customer extends Person {
// Inherits name and age
// automatically from Person
int custId;
String phone;
}

I compile Person.java
and get good compile:
D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Person.java



but when I compile Customer.java; I get error.
D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Customer.java
Customer.java:1: cannot resolve symbol
symbol : class Person
location: class Customer
class Customer extends Person {
^
1 error

apparently it doesnot understand the word extends?????

Thanks
 
F

frabi

George Kooper said:
I have installed Java from Sun site to my Windows XP .

I have modified the PATH statement to include:
C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program
Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program
Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft
VisualStudio\VC98\bin;C:\j2sdk1.4.2_03\bin;


I have 2 files in my directory:
Person.class:
class Person {
String name;
int age;
}

and
Customer.java:
class Customer extends Person {
// Inherits name and age
// automatically from Person
int custId;
String phone;
}

I compile Person.java
and get good compile:
D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Person.java



but when I compile Customer.java; I get error.
D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Customer.java
Customer.java:1: cannot resolve symbol
symbol : class Person
location: class Customer
class Customer extends Person {
^
1 error

apparently it doesnot understand the word extends?????

Thanks

Hi!

I think you should make both classes Public, so they can be seen from
outside of the source files:

public class Persion {
....
}

and

public class Cusomer {
....
}

now the class Customer sould be able to access class Person.
Surprisingly i could compile both files with jdk1.3.1. what version do you
use?

best regards
alex
 
T

Thomas Schodt

George said:
D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Customer.java
Customer.java:1: cannot resolve symbol
symbol : class Person
location: class Customer
class Customer extends Person {
^
1 error

apparently it doesnot understand the word extends?????

That's not what it says.

Customer.java:1: cannot resolve symbol
symbol : class Person
location: class Customer
class Customer extends Person {
^

The caret (^) points to Person.

Presumably the classpath you gave javac to work with
does not include the current directory (".").
 
A

Andrew Thompson

| I have installed Java from Sun site to my Windows XP .
|
| I have modified the PATH statement to include:

That is apperently the old way to do it,
it is better to set classpath when calling
java or javac.

| I have 2 files in my directory:
....
| class Person {
.....
| class Customer extends Person {

Since neither is 'public' you could combine
them in one file and compile them together,
but that does not really address the wider
problem of the paths..

| I compile Person.java
| and get good compile:
| D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Person.java
....
| but when I compile Customer.java; I get error.
| D:\javaschool\Labs\02_JavaDataTypes\Starter>javac Customer.java
| Customer.java:1: cannot resolve symbol
| symbol : class Person
| location: class Customer
| class Customer extends Person {
| ^
| 1 error

That is odd. Not the error itself, but
that you did not notice the little '^'
was pointing to Person*, not extends..

[ * Using a fixed width font, it certainly does ]

Another clue is the error message itself,
which states..

Customer.java:1: cannot resolve symbol
symbol : class Person

Get the command line options right, and
it should work. (I tested the code in a single
file, it works. If you would like to check
it yourself easily, surf on over to..
http://www.physci.org/javac.jsp.
I told it the 'public' class was Person,
and it works fine..)

Lastly, at this stage in your Java experience,
you may be better off posting to c.l.j.help,
which is more suited to such questions..

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top