Why doesn't JDK read from within a package?

Using the Java SDK with TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
User avatar
jon80
Posts: 24
Joined: Thu May 28, 2009 10:03 am

Why doesn't JDK read from within a package?

Post by jon80 »

Code: Select all

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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

How is your classpath configured? Does it contain . (dot = current directory)?
User avatar
jon80
Posts: 24
Joined: Thu May 28, 2009 10:03 am

Post by jon80 »

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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

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)
User avatar
jon80
Posts: 24
Joined: Thu May 28, 2009 10:03 am

Post by jon80 »

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
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

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)
Post Reply