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 you following command to package in jar file. > jar cvf myejb.jar p1 Here p1 is the packag

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" ) ;          JButton  b2 = new   JButton ( "2" ) ;          JButton  b3 = new   JButton ( "3" ) ;          JButton  b4 = new   JButton ( "4" ) ;          JButton  b5 = new   JButton ( "5" ) ;          JButton  b6 = new   JButton ( "6" ) ;          JButton  b7 = new   JButton ( "7" ) ;          JButton  b8 = new   JButton ( "8" ) ;          JButton  b9 = new