1 10 11 package converterclient; 12 import converter.ConverterRemote; 13 import converter.ConverterRemoteHome; 14 import javax.naming.Context ; 15 import javax.naming.InitialContext ; 16 import javax.rmi.PortableRemoteObject ; 17 import java.math.BigDecimal ; 18 19 20 public class ConverterClient { 21 public static void main(String [] args) { 22 try { 23 Context initial = new InitialContext (); 24 Object objref = initial.lookup("ejb/SimpleConverter"); 25 26 ConverterRemoteHome home = (ConverterRemoteHome) PortableRemoteObject.narrow(objref, ConverterRemoteHome.class); 27 28 ConverterRemote currencyConverter = home.create(); 29 30 BigDecimal param = new BigDecimal ("100.00"); 31 BigDecimal amount = currencyConverter.dollarToYen(param); 32 33 System.out.println(amount); 34 amount = currencyConverter.yenToEuro(param); 35 System.out.println(amount); 36 37 System.exit(0); 38 } catch (Exception ex) { 39 System.err.println("Caught an unexpected exception!"); 40 ex.printStackTrace(); 41 } 42 } 43 } | Popular Tags |