• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

package problem

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The accountbalance class should have a package statement.
package cert.java;
reply
    Bookmark Topic Watch Topic
  • New Topic