I made two java files in the same directory. // Pac.java - first file package pac; public class Pac{ } // SPac.java - second file package pac; public class SPac{ Pac p; } When I compiled SPac.java, the compiler complained that it couldn't understand the symbol Pac. Then I deleted package statement from both of them and that time Spac.java was compiled fine. Why is that? Please give me some help. Thanks in advance.
Your classes need to be in directory "pac" and this directory needs to be in your classpath. Pho
Regards,
Pho
Toru Saito
Greenhorn
Joined: Oct 11, 2001
Posts: 4
posted
0
Thank for reply, Pho. I put those two files in c:\java\programming\pac directory and set CLASSPATH in autoexec.bat: SET CLASSPATH=.;c:\java\programming\pac; (By the way my os is Win95) Then I rebooted the computer and tried to compile it again. But it didn't work. Is there something wrong with the way to set CLASSPATH or what?
Michael Bruesch
Ranch Hand
Joined: Sep 23, 2001
Posts: 158
posted
0
Leave off the actual folder where your package begins, just direct the classpath to the directory where your packages are stored like so: SET CLASSPATH=.;c:\java\programming I'm no classpath expert, but I had this very problem not 2 days ago, and this worked for me.
Michael J Bruesch<br /><i>I code, therefore I am.</i>
Toru Saito
Greenhorn
Joined: Oct 11, 2001
Posts: 4
posted
0
Thanks Michael. That worked!!
Michael Bruesch
Ranch Hand
Joined: Sep 23, 2001
Posts: 158
posted
0
As far as I'm concerned, that's the best way to learn, mess up, then try again and get it right. That's how I always do it! (Although it may not be the easiest way).