aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What's wrong?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What Watch "What New topic
Author

What's wrong??

chao-long liao
Ranch Hand

Joined: Jul 29, 2001
Posts: 78
//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

Joined: Jul 29, 2001
Posts: 78
ohoh,there is onething wrong.
The symbol " ^ " is under the letter " V " of Vehicle.
help.
chao-long liao
Ranch Hand

Joined: Jul 29, 2001
Posts: 78
And there is still one thing.
The Car.java and Vehicle.java are in the same
directory.
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
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!!


MT
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
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 ]
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Hi, chao-long
Try this
java -classpath . Car
Jamal Hasanov
www.j-think.com
chao-long liao
Ranch Hand

Joined: Jul 29, 2001
Posts: 78
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.
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
There can be only ONE public class in a source file !!
chao-long liao
Ranch Hand

Joined: Jul 29, 2001
Posts: 78
They are in different files.
manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Keep both the java files in a complete different directory and compile and see.. Once, I had similar problem..
Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
I use UltraEdit 9.00a and it worked fine, one thing that might help is writing "%P" in the Working Directory field.
Francisco


Francisco<br />SCJP<br />please use the [code][/code] tags when showing code.Click <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">here</a> to see an example.
chao-long liao
Ranch Hand

Joined: Jul 29, 2001
Posts: 78
>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

Joined: Jul 29, 2001
Posts: 78
>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?
 
 
subject: What's wrong??