| Author |
cannot find symbol
|
Urs Waefler
Ranch Hand
Joined: Mar 13, 2007
Posts: 77
|
|
Hi I have a very basic problem, I think, I am crazy? There are two files: public class Z{} public class Y extends Z {} These two files are saved in the same folder. I can not compile the file called Y.java. This is the message: cannot find symbol symbol class Z public class Y extends Z {} What is wrong? Urs
|
SCJP 1.4
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
You haven't given enough details. Do the two files have package declarations? In which case you might only be able to compile them in the order Z--->Y. Try that.
|
 |
Urs Waefler
Ranch Hand
Joined: Mar 13, 2007
Posts: 77
|
|
They do not have package declarations. It is very basic. Z.java Y.java The source code is writen above. It is really a stupid problem, but I need to understand it.
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
|
are the files both named correctly? is your CLASSPATH set?
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Bill Shirley
Ranch Hand
Joined: Nov 08, 2007
Posts: 457
|
|
show us your actual code, show us the actual error message, use code tags!
|
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
|
 |
Urs Waefler
Ranch Hand
Joined: Mar 13, 2007
Posts: 77
|
|
There are two files saved in the same folder: Z.java: public class Z{} Y.java: public class Y extends Z {} That is all. I can compile the file Z.java. But I can not compile the file Y.java. I get the following message: cannot find symbol symbol class Z public class Y extends Z {}
|
 |
Abhinav Srivastava
Ranch Hand
Joined: Nov 19, 2002
Posts: 345
|
|
Is the folder where Z.class is generated in the CLASSPATH? If you have "." in the classpath, you should be able to compile from the folder where Z.class is present.
|
 |
Urs Waefler
Ranch Hand
Joined: Mar 13, 2007
Posts: 77
|
|
I have saved both files on the desktop. I added CLASSPATH in the environment variable. C:\Dokumente und Einstellungen\Urs W�fler\Desktop This is saved in CLASSPATH. But it does not work. I do not properly understand CLASSPATH.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
cd C:\Dokumente und Einstellungen\Urs W�fler\Desktop javac -classpath . Y.java
|
[Jess in Action][AskingGoodQuestions]
|
 |
Sunny Jain
Ranch Hand
Joined: Jul 23, 2007
Posts: 433
|
|
Hi, Do one thing, First after compiling z.java..search it class file where it got generated...compiler is not able to find out that file..!!
|
Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
|
 |
Urs Waefler
Ranch Hand
Joined: Mar 13, 2007
Posts: 77
|
|
It worked. javac -classpath . Y.java This was the solution. Thank you.
|
 |
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3327
|
|
That's great! You can get to know about these common problems here. Also you can read this thread about How to set the classpath
|
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
|
 |
 |
|
|
subject: cannot find symbol
|
|
|