Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can you help me please?: error whtih inheritance

 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to compile but i always have the same error. I have 2 class in the same package,one abc and the other is def ; Here you can see my class :
public class abc {
public abc(){}
}

public class def extends abc {
public static void main(String arg[]) {
System.out.println("compiled and executed");
}
}

I have this error:

def.java:1: cannot resolve symbol
symbol : class abc
location: class def
public class def extends abc {
^
1 error
Can you answer please.....thanks a lot!
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are both .java files in the same directory?
How are you compiling these files?
It could be that you don't have your classpath set up correctly.
How are you compiling both of the files?
you should probably be in the same directory as the two files when you type javac, then you can type
javac -classpath ./ def.java
and the compiler will be able to find the referenced abc.java file.
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okucuen
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
 
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob , it's very nice from you?You're right. i had a problem whith my environnement variable. Classpath and path !!I changed it.
Dave , i thanks you so, As you can see , i have my name changed
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic