-----A file called Car.java has the following lines-----
class Car{
int price, year;
public Car(int p, int y){
price = p;
year = y;
}
public int getPrice(){
return price;
}
public int getYear(){
return year;
}
}
-----And another file called testCar.java contains main method, -----
public class testCar{
public static void main(String[] args){
Car c = new Car(2000,1993);
System.out.println(c.getPrice());
}
}
-----No problem in compiling Car.java. However, it gives me the following
-----errors when compiling testCar.java-----
cannot resolve symbol
symbol : class Car
location: class testCar
Car c = new Car(2000,1993);
^
D:\Documents and Settings\yangxingdong\Desktop\testJava\testCar.java:3: cannot resolve symbol
symbol : class Car
location: class testCar
Car c = new Car(2000,1993);
^
2 errors
Tool completed with exit code 1
-----Anyone has idea how to solve the problem? -----
JAVA compiler can't find class file in the same folder...
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Just a guess here
http://www.textpad.info/forum/viewtopic ... lve+symbol
Yet another guess
http://www.textpad.info/forum/viewtopic.php?t=4290
Check out this one too, always a useful link. http://www.textpad.info/forum/viewtopic.php?t=4702
[edit]
Additionally, I saved your information out into 2 files as indicated. Compiled Car.java, compiled testCar.java, executed the testCar.class and it printed 2000.
Java 1.4.1
[/edit]
http://www.textpad.info/forum/viewtopic ... lve+symbol
Yet another guess
http://www.textpad.info/forum/viewtopic.php?t=4290
Check out this one too, always a useful link. http://www.textpad.info/forum/viewtopic.php?t=4702
[edit]
Additionally, I saved your information out into 2 files as indicated. Compiled Car.java, compiled testCar.java, executed the testCar.class and it printed 2000.
Code: Select all
javac Car.java
javac testCar.java
java testCar
[/edit]
I choose to fight with a sack of angry cats.
- talleyrand
- Posts: 624
- Joined: Mon Jul 21, 2003 6:56 pm
- Location: Kansas City, MO, USA
- Contact:
Still sounds like the classpath may not be set up correctly. Again, a search for NoClassDefFoundError within the TextPad forums or via Google.
Happy hunting
Happy hunting
I choose to fight with a sack of angry cats.
don't let talleyrand discourage you...
there is an easy solution to this problem.
right-click my computer, click properties
select the advanced tab
click the environmental variables button at the bottom
under system variables, there should be a variable named CLASSPATH, if so, change its value to '.' (no quotes, just a period)
if not, click new, and add a variable with name CLASSPATH and value of .
that should take care of your problem, and now in the future if other users search the forums, they might find something useful as opposed to unhelpful posts telling them to perform another search
there is an easy solution to this problem.
right-click my computer, click properties
select the advanced tab
click the environmental variables button at the bottom
under system variables, there should be a variable named CLASSPATH, if so, change its value to '.' (no quotes, just a period)
if not, click new, and add a variable with name CLASSPATH and value of .
that should take care of your problem, and now in the future if other users search the forums, they might find something useful as opposed to unhelpful posts telling them to perform another search
- s_reynisson
- Posts: 939
- Joined: Tue May 06, 2003 1:59 pm