Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package problem

 
prashant patel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was practicing this package example from "java2 complete refrence"
package cert.java;
class Balance
{
String name;
double bal;
Balance( String n, double b )
{
name = n;
bal = b;
}

void show()
{
if( bal > 0 )
{
System.out.println("--->");
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"
 
CSR Rao
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The accountbalance class should have a package statement.
package cert.java;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic