Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1443067
  • 博文数量: 3500
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 43870
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-03 20:31
文章分类

全部博文(3500)

文章存档

2008年(3500)

我的朋友

分类:

2008-05-04 23:40:57

一起学习
1。所先下载J2SDKEE1.3和J2SDK1.4,jakarta-ant1.3, 其中J2SDKEE和J2SDK1.4可以从免费下载。 2。点击安装,我这边是安装在D盘下 3。进行环境设置: 右击我的电脑/属性/高级/环境变量/系统变量 点击path,在其变量值后面加入:;D:\j2sdk\bin;D:\j2sdkee\bin;D:\jakarta-ant1.3\bin; 点击classpath,在其变量值后面加入:;D:\j2sdk\lib\dt.jar;D:\j2sdk\lib\tools.jar;D:\j2sdk\jre\lib\rt.jar;D:\j2sdkee\lib\j2ee.jar; 其中D:\j2sdkee为J2SDKEE的安装路径,D:\j2sdk和D:\jakarta=ant1.3同样。 4。测试: 在IE中输入:如果安装成功就会出现J2EE的介面; 如果不行,可能是在你电脑上的8000端口被其它软件占用了,发生了冲突。这时你就要改一下进入D:\j2sdkee\config中把web.properties中的http.port=8000的8000改成其它没有冲突端口号。 5。启动J2EE 进入命令提示符,输入:start j2ee -verbose启动J2EE。 输入:start deploytool启动应用程序配置工具进行配置。 下而一个例子: Home接口: import java.rmi.RemoteException; import java.io.Serializable; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface ConverterHome extends EJBHome { Converter create() throws RemoteException,CreateException; } Remote接口: import javax.ejb.EJBObject; import java.rmi.RemoteException; import java.math.*; public interface Converter extends EJBObject { public BigDecimal dollarToYen(BigDecimal dollars)throws RemoteException; public BigDecimal yenToEuro(BigDecimal yen)throws RemoteException; } Bean类: import java.rmi.RemoteException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; import java.math.*; public class ConverterBean implements SessionBean { BigDecimal yenRate=new BigDecimal("121.6000"); BigDecimal euroRate=new BigDecimal("0.0077"); public BigDecimal dollarToYen(BigDecimal dollars) { BigDecimal result=dollars.multiply(yenRate); return result.setScale(2,BigDecimal.ROUND_UP); } public BigDecimal yenToEuro(BigDecimal yen) { BigDecimal result=yen.multiply(euroRate); return result.setScale(2,BigDecimal.ROUND_UP); } public ConverterBean() {} public void ejbCreate(){} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {} } Client程序: import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import java.math.BigDecimal; import Converter; import ConverterHome; public class ConverterClient { public static void main(String[] args) { try{ Context initial=new InitialContext(); Object objref=initial.lookup("java:comp/env/ejb/SimpleConverter"); ConverterHome home=(ConverterHome)PortableRemoteObject.narrow(objref,ConverterHome.class); Converter currencyConverter=home.create(); BigDecimal param=new BigDecimal("100.00"); BigDecimal amount=currencyConverter.dollarToYen(param); amount=currencyConverter.yenToEuro(param); System.exit(0); } catch (Exception ex) { System.err.println("Caught an unexpected exception!"); ex.printStackTrace(); } } } 下载本文示例代码


Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置Windows 2000 server下j2ee jdk ant的配置
阅读(235) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~