Cannot find Symobl why?

Hi,

I have one problem.

When I create any project using Textpad or JCreator and if I am using packages when I create object of another class which is in same package then I get error thatcannot find symbol

why this happens?

consider this

package demo;

import java.io.*;

publicclass Two

{

public Two()

{

}

public String getTwo()

{

return"2";

}

}

//this is a Simple class

package demo;

import java.io.*;

publicclass One

{

publicstaticvoid main(String args[])

{

Two t;

}

}

this is the class in the same package in which I am creating the object ofTwo class.

But when I try to compile One.java file then error comescannot find symbol : Two t;

[1621 byte] By [student@sunDNa] at [2007-11-27 10:38:08]
# 1

Did you compile Two.java first?

georgemca at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 2

yes I did it.

student@sunDNa at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 3

And Two.class is in

C:\some\path\demo

so is

C:\some\path

in the classpath?

(Not the CLASSPATH env var. Your IDE's classpath setting for that project.)

jverda at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 4

Both the files are in

C:\My Projects\demo\

but still this problem comes!

So what can I do then?

I mean how can I use the classes from same package?

do I have to set CLASSPATH for it?

student@sunDNa at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 5

> Both the files are in

> C:\My Projects\demo\

> but still this problem comes!

> So what can I do then?

> I mean how can I use the classes from same package?

> do I have to set CLASSPATH for it?

Not CLASSPATH (which is an environment variable, and best left well alone) but a classpath. The documentation for your IDE will tell you how to do this

georgemca at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 6

Thanx you all.

I got it.

student@sunDNa at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 7

Cool. What was the problem?

georgemca at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 8

about using Classes from the same package.

student@sunDNa at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 9

> about using Classes from the same package.

Yeh, I know that bit. I mean, what did you do to fix it, in case anyone else has the same problem in future?

georgemca at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...
# 10

I add the path of my folder in the classpath of my Env. var.

and then tried, it works.

student@sunDNa at 2007-7-28 18:52:35 > top of Java-index,Java Essentials,Java Programming...