I created the following package AccBal.
package AccBal;
public class AccountBalance
{
private String Name;
private double Balance;
public void setData(String name, double balance)
{
Name=name;
Balance=balance;
}
public void displayBalance()
{
System.out.println("The Account Balance of " + Name + " is $"+Balance);
}
}
Then I created a class to use this package:
import AccBal.*;
import java.util.Scanner;
import java.io.Console;
class Bank
{
public static void main()
{
byte n;
//char []tempname;
String name;
double Balance;
Scanner input=new Scanner(System.in);
Console cin=System.console();
System.out.print("Enter the number of Customers: ");
n=input.nextByte();
AccountBalance [] acc=new AccountBalance[n];
for(byte i =0;i<n;i++)
{
System.out.println("\nEnter the Name and Account Balance of customer " + (i+1) + ":");
name=cin.readLine();
//name=new String(tempname);
Balance=input.nextDouble();
acc[i].setData(name,Balance);
}
System.out.println("\nThe Details of the Customers are: ");
for(byte i =0;i<n;i++)
{
acc[i].displayBalance();
}
}
}
My Directory Structure is as follows:
[B]Main Directory:[/B]
Name : [B]Bank[/B]
Contents: Bank.class, Bank.java, AccBal (subDir)
[B]AccBal Contents:[/B]
AccountBalance.class
I use JDK 1.6 and JRE 1.5 "with no IDE" I use the cmd pmt to compile and run the code.
When I compile it I get no error, but when I run the bytecode, I get following exception as an error:
E:\JAVA Programs\Bank>java Bank
Exception in thread "main" java.lang.NoSuchMethodError: main
Please Help me!