Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why doesn't JDK read from within a package?

 
Post new topic   Reply to topic    Community Forum Index -> Java
View previous topic :: View next topic  
Author Message
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Sat May 19, 2012 2:03 pm    Post subject: Why doesn't JDK read from within a package? Reply with quote

Code:
package food;
class Dog
{

}
package food;
class Terrier extends Dog
{
   void walk()
   {
      System.out.println("Terrier walks");
   }
}


Error
C:\Documents and Settings\Jon\Desktop\food\Terrier.java:2: error: cannot find symbol
class Terrier extends Dog
^
symbol: class Dog
1 error

Tool completed with exit code 1 [/b]
_________________
Jon
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
MudGuard



Joined: 02 Mar 2003
Posts: 1254
Location: Munich, Germany

PostPosted: Sat May 19, 2012 6:47 pm    Post subject: Reply with quote

How is your classpath configured? Does it contain . (dot = current directory)?
Back to top
View user's profile Send private message Visit poster's website
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Sat May 19, 2012 8:01 pm    Post subject: Reply with quote

MudGuard wrote:
How is your classpath configured? Does it contain . (dot = current directory)?

Yep

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jon>echo %CLASSPATH%
.;C:\Program Files\Java\external_jars\junit4.9b2\junit4.9b2\junit-4.9b2.jar;C:\P
rogram Files\PostgreSQL\pgJDBC;

C:\Documents and Settings\Jon>
_________________
Jon
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
MudGuard



Joined: 02 Mar 2003
Posts: 1254
Location: Munich, Germany

PostPosted: Fri May 25, 2012 7:20 pm    Post subject: Reply with quote

I found a solution.

file TestOne.java lies in a folder called one (otherwise, package one; would make no sense).

so to find the way from TestOne to one/Dog.java, the classpath needs to contain the folder containing folder one (either relatively referenced by .. or as absolute path)
Back to top
View user's profile Send private message Visit poster's website
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Fri May 25, 2012 8:05 pm    Post subject: Reply with quote

MudGuard wrote:
I found a solution.

file TestOne.java lies in a folder called one (otherwise, package one; would make no sense).

so to find the way from TestOne to one/Dog.java, the classpath needs to contain the folder containing folder one (either relatively referenced by .. or as absolute path)


Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Jon>echo %CLASSPATH%
.;C:\Program Files\Java\external_jars\junit4.9b2\junit4.9b2\junit-4.9b2.jar;C:\P
rogram Files\PostgreSQL\pgJDBC;

C:\Documents and Settings\Jon>%CLASSPATH%=%CLASSPATH%;C:\Documents and Settings\
Jon\Desktop\food
'.' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Jon>%CLASSPATH%=%CLASSPATH%,C:\Documents and Settings\
Jon\Desktop\food
'.' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Jon>SET %CLASSPATH%=%CLASSPATH%,C:\Documents and Setti
ngs\Jon\Desktop\food

C:\Documents and Settings\Jon>echo %CLASSPATH%
.;C:\Program Files\Java\external_jars\junit4.9b2\junit4.9b2\junit-4.9b2.jar;C:\P
rogram Files\PostgreSQL\pgJDBC;

C:\Documents and Settings\Jon>
_________________
Jon
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
MudGuard



Joined: 02 Mar 2003
Posts: 1254
Location: Munich, Germany

PostPosted: Fri May 25, 2012 8:25 pm    Post subject: Reply with quote

you need to learn the syntax of the set command ('help set' should help you)


(and you need to learn the difference between comma and semicolon)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB