KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > converterclient > ConverterClient


1 /*
2  * ConverterClient.java
3  *
4  * Created on May 3, 2005, 4:37 PM
5  *
6  * To change this template, choose Tools | Options and locate the template under
7  * the Source Creation and Management node. Right-click the template and choose
8  * Open. You can then make changes to the template in the Source Editor.
9  */

10
11 package converterclient;
12 import converter.ConverterRemote;
13 import converter.ConverterRemoteHome;
14 import javax.naming.Context JavaDoc;
15 import javax.naming.InitialContext JavaDoc;
16 import javax.rmi.PortableRemoteObject JavaDoc;
17 import java.math.BigDecimal JavaDoc;
18
19
20 public class ConverterClient {
21     public static void main(String JavaDoc[] args) {
22         try {
23             Context JavaDoc initial = new InitialContext JavaDoc();
24             Object JavaDoc objref = initial.lookup("ejb/SimpleConverter");
25
26             ConverterRemoteHome home = (ConverterRemoteHome) PortableRemoteObject.narrow(objref, ConverterRemoteHome.class);
27
28             ConverterRemote currencyConverter = home.create();
29
30             BigDecimal JavaDoc param = new BigDecimal JavaDoc("100.00");
31             BigDecimal JavaDoc 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 JavaDoc ex) {
39             System.err.println("Caught an unexpected exception!");
40             ex.printStackTrace();
41         }
42     }
43 }
Popular Tags