
package bean; public interface AccountsDAOI{ double getBalance(int accno); void setBalance(int accno,double amt); } // package bean;
public class AccountsDAO implements AccountsDAOI{
public void setBalance(int accno,double amt){
}
public double getBalance(int accno){
return 1000.0;
}
}
//
package bean;
public class CheckMinBal{
public boolean CheckBalance(int accno,double amt){
return(amt>0);
}
}
//
package bean;
public class AccountOperations{
public AccountOperations(AccountsDAOI adao){
accountsDAO=adao;
}public void Withdraw(int accno,double amt){
double bal=accountsDAO.getBalance(accno);
bal-=amt;
if(checkMinBal.CheckBalance(accno,bal)){
accountsDAO.setBalance(accno,bal);
System.out.println("withdraw success");
}}
public void deposit(int accno, double amt){
double bal=accountsDAO.getBalance(accno);
bal+=amt;
accountsDAO.setBalance(accno,bal);
System.out.println("Deposit success");
}
public void setCheckMinBal(CheckMinBal cmb){
checkMinBal=cmb;
}
private AccountsDAOI accountsDAO;
private CheckMinBal checkMinBal;
}
//
package bean;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.xml.*;
import org.springframework.core.io.*;
import bean.AccountOperations;
public class SpringContainerTestCase{
public static void main(String a[]){
BeanFactory beans=new XmlBeanFactory(new FileSystemResource("MyBeans.xml"));
AccountOperations ao=(AccountOperations)beans.getBean("accOperations");
ao.Withdraw(101,100);
}
}
//
when i'm trying this code in myeclipse it got executed. but its not working normally.
i set the classpath=D:\java softwares\ST-IV\Spring\spring-framework-2 .5.1\dist\spring.jar;D:\java softwares\ST-IV\Spring\spring-framework-2.5.1\lib\c ommonj\commonj-twm.jar;D:\java softwares\ST-IV\Spring\spring-framework-2.5.1\lib \log4j\log4j.jar
error:Exception in thread "main" java.lang.NoClassDefFoundError: SpringContainerTestCa se