File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package problem" Watch "package problem" New topic

package problem

prashant patel
Ranch Hand

Joined: May 02, 2000
Posts: 69
I was practicing this package example from "java2 complete refrence"
class Balance
String name;
double bal;
Balance( String n, double b )
name = n;
bal = b;

void show()
if( bal > 0 )
System.out.println(name + " :$" + bal);

class AccountBalance
public static void main(String args[])
Balance current[] = new Balance[3];
current[0] = new Balance("prahant" , 4000);
current[1] = new Balance("chaita" , 5000);
current[2] = new Balance("usha" , 6000);
for(int i = 0; i < 3; i++)<br /> {<br /> current[i].show();<br /> }<br /> }<br /> }<br /> <br /> I have a directory in my C: named c:\cert\java; the source and class files are included in the <br /> same directory but when i try to execute the class file using <br /> 1) C:\cert> java java.AccountBalance -- as described by "patrick" go one level up and execute
the class file.
2) c:\cert\java> java.AccountBalance.-- give the same exception noclassdeffounderror.
now i even tried setting the classpath variable to

set classpath=C:\cert\java; C:\jdk1.2.2\lib\tools.jar; C:\jdk1.2.2\lib\dt.jar;
this is silly but do i have to specify the jdk path
Please explain me why the classpath is classes the classpath "variable"


Joined: Mar 31, 2007
Posts: 6
The accountbalance class should have a package statement.

Regards,<br />CSR.
I agree. Here's the link:
subject: package problem
It's not a secret anymore!