Skip to main content

Posts

Showing posts from September, 2009

EJB3 | Stateless session bean

To build a statelesss session bean in EJB3, you need to create one interafce and on class. Interface is implemented by class and methods declared in the interaface are available to client for remote access. Bean class and interaface should be public. Bean class is annotated with the annotation @Stateless(mappedName="something") and interafce is annotated with @Remote annotation. Both are compiled and packed in jar file. Coding for Remote Interface package p1; import javax.ejb.Remote; @Remote public interface AdderIntf{     int add(int x,int y); } Coding for Bean class package p1; import javax.ejb.Stateless; @Stateless(mappedName="abc") public class Adder implements AdderIntf{     public int add(int x,int y){         System.out.println("x="+x+" , y="+y);         int z=x+y;         return z;     } } Both are compiled and packaged in jar file. you can y...

Calculator in java swing

import  javax.swing. * ; import  java.awt. * ; import  java.awt.event. * ; import  java.io. * ; class  gui1 {      static   double  a = 0 ;      static   int  op = 0 ;      public   static   void   main ( String  ar []){                   JFrame  f1 = new   JFrame ( "Calculator" ) ;         f1. setLayout ( null ) ;          final   JTextField  t1 = new   JTextField ( 100 ) ;         t1. setBounds ( 10 , 10 , 200 , 30 ) ;          JButton  b0 = new   JButton ( "0" ) ;          JButton  b1 = new   JButton ( "1" ) ;   ...