cannot find package/class symbol

hello. i'm using netveans for the first time. i have a java application with 2 classes... pb.java with public class pb int package svr and cl.java with public class cl in package cli

that is..

fileclasspackage

pbpb svr

clclcli

pb.java compiles properly cl.java gioves error.

the error is in the following lines of code...

pb obj1 =new pb();

pb obj2 =new pb();

i'm trying to make an object fo type pb from cl.java. the error i get is...

cannot find symbol

class pb

location cli.cl

i alse tried puttin svr.pb instead of pb but no use.

the entire cose is as follows...

pb.java

/*

* pb.java

*

* Created on December 4, 2006, 8:56 AM

*

*/

package svr;

publicclass pb

{

privatedouble balance;

privatedouble []lt =newdouble [10];

privateint i=9;

publicvoid deposit(double amt)

{

if(amt<=0)

{

System.out.println("Enter amount greater than 0");

}

else

{

balance=balance+amt;

if(i>=0)

{

lt[i]=amt;

}

else

{

for(int j=9;j>=0;j--)

{

lt[i]=lt[i-1];

}

lt[0]=amt;

}

}

}

publicvoid withdraw(double amt)

{

if(amt<=0)

{

System.out.println("Enter amount greater than 0");

}

else

{

if(amt>balance)

{

System.out.println("Balance lower than amount entered");

}

else

{

balance=balance-amt;

if(i>=0)

{

lt[i]=-amt;

}

else

{

for(int j=9;j>=0;j--)

{

lt[i]=lt[i-1];

}

lt[0]=-amt;

}

}

}

}

publicvoid bal()

{

System.out.println("Balance: "+balance);

}

publicvoid lts()

{

System.out.println("Last 10 Transactions");

for(int j=i;j>10;j++)

{

System.out.println(lt[j]);

}

}

publicvoid statement()

{

lts();

bal();

}

}

cl.java

/*

* cl.java

*

* Created on December 4, 2006, 8:58 AM

*

*/

package cli;

class cl

{

publicstaticvoid main(String[] args)

{

pb obj1 =new pb();

pb obj2 =new pb();

obj1.deposit(100.50);

obj1.statement();

obj2.deposit(200.75);

obj2.statement();

obj1.withdraw(25.50);

obj1.statement();

obj2.withdraw(100.25);

obj2.statement();

}

}

[5470 byte] By [kothari_neerava] at [2007-10-3 11:30:03]
# 1
If they are in different packages then you will need import statements.
floundera at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 2
can u please tell me more about import statements... like how to declare them.
kothari_neerava at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 3

try to learn more about Java...

you declared pb class on this packager -> "svr"

that's why you have this: package svr;

so if you're goin to use pb like what you did from you code above you should import it like this:

import svr.pb;

but first of all.. try to finished the Java tutorials

angeles1016a at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 4
pls dont ask foolish questions. first try to refer on basics of java with some java books
daveknirava at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 5

> can u please tell me more about import statements...

> like how to declare them.

Won't netbeans automatically put in the import statements for you? Isn't there a UI page of compilation errors (in this case just this one) where you are given some suggestions on how to fix them?

For a beginner those tools will come in handy, since the biggest thing about beginning is working your way through all the compilation errors. I bet netbeans gives that kind of aid, but if not try out a few other IDEs.

bheilersa at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 6

hello all.

i imported the package and it worked fine.

sorry but i'm little impulsive about things. we have been tought java through command prompt so far and there we didn't have to import anything. i'm trying to be a little bit ahead of my tutorials as that way i can have doubts ready.

anyway, thanks for your kind support.

Neerav

kothari_neerava at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 7

> sorry but i'm little impulsive about things. we have

> been tought java through command prompt so far and

> there we didn't have to import anything.

It has absolutely nothing to do with the command prompt. And scrap Netbeans and stick with the prompt, I advise, unless you start using an IDE in school too.

CeciNEstPasUnProgrammeura at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 8

> For a beginner those tools will come in handy, since

> the biggest thing about beginning is working your way

> through all the compilation errors. I bet netbeans

> gives that kind of aid, but if not try out a few

> other IDEs.

For a beginner these tools are worst, because they hide all the stuff a programmer needs to know to find his way around Java. They should spend a few weeks with the command line and a good text editor before switching.

Just because an IDE does something for you, it doesn't mean you don't need to kno wwhat it does.

Unless you volunteer to handle all "how do I do X in Netbeans/Eclipse/Whatever", JAR and classpath questions posted here by newbies yourself.

CeciNEstPasUnProgrammeura at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...
# 9

> For a beginner these tools are worst, because they

> hide all the stuff a programmer needs to know to find

> his way around Java. They should spend a few weeks

> with the command line and a good text editor before

> switching.

>

> Just because an IDE does something for you, it

> doesn't mean you don't need to kno wwhat it does.

>

> Unless you volunteer to handle all "how do I do X in

> Netbeans/Eclipse/Whatever", JAR and classpath

> questions posted here by newbies yourself.

I suppose I can agree with that to some extent. I wouldn't suggest to anyone that they just blindly trust whatever code the IDE inserts automatically.

But there's nothing wrong about learning by example. The IDE is willing to teach proper syntax, and eclipse will give suggestions about capitalizing class names and making constants all-caps.

There are things that frustrate new programmers where an IDE will be helpful, especially if the entire API is uncharted territory.

bheilersa at 2007-7-15 13:56:36 > top of Java-index,Java Essentials,Java Programming...