• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's wrong??

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
//Vehicle.java
public class Vehicle {
int d = 10;
public void drive() {
System.out.println("Vehicle: drive");
}
}
//compile OK.
//Car.java
public class Car extends Vehicle {
int d = 20;
public void drive() {
System.out.println("Car: drive");
}
}
//compile error.
cannot resolve symbol
symbol:class Vehicle
location:class Car
public class Car extends Vehicle {
^
1 error
Oops,can someboey tell me what's wrong??
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohoh,there is onething wrong.
The symbol " ^ " is under the letter " V " of Vehicle.
help.
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And there is still one thing.
The Car.java and Vehicle.java are in the same
directory.
 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code works fine for me.
I guess, you didn't keep them in the same directory and compile. Keep them in the same place and run. It works!!
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you already kept them in the same directory, I guess, the name of files could be the reason for the compilation error
Please verify the file name "Vehicle.java".
I guess, you might have given the file/class name as
vehicle.java .
and, in car.java, You have used
public class Car extends Vehicle {
that gives you the problem. As Java is case senitive, its not finding the Vehicle in Car.java
Hope that helps!!
murthy
[ June 18, 2002: Message edited by: Murthy Ram ]
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, chao-long
Try this
java -classpath . Car
Jamal Hasanov
www.j-think.com
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sure the case is correct.
I use ultraedit 9.00a to compile and run java,I think maybe that is the problem.
Maybe the problem is path or classpath.
>Hi,chao-long
>try this
>java -classpath . Car
I can't try,because I am not administrator,I have no access,I can only use ultraedit.
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There can be only ONE public class in a source file !!
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are in different files.
 
manasa teja
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keep both the java files in a complete different directory and compile and see.. Once, I had similar problem..
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use UltraEdit 9.00a and it worked fine, one thing that might help is writing "%P" in the Working Directory field.
Francisco
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>one thing that might help is writing "%P" in the >Working Directory field.
I try it,and error.
D:\test\Vehicle.java:1: error while writing Vehicle: D:\test\Vehicle.class(access deny)
class Vehicle {
^
1 error
 
chao-long liao
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Keep both the java files in a complete different >directory and compile and see.. Once, I had >similar problem..
The same error message in the beginning.
I think it's the problem of classpath.
Maybe it's classpath didn't set properly,the important sign "." forgot to set.
But again I have no access to check and modify it,
so how should I do?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic