入门的时候看了网上不少有关j2ee的开发平台的搭建的文章,自己做起来不是这出问题就是那出问题。没法,看着人家的官方教程做吧!
一、欲善其事,先利其器
需要的工具:
sun公司的jdk(http://java.sun.com),
eclipse(http://www.eclipse.org),
lomboz3.01(http://download.us.forge.objectweb.org/lomboz/lomboz.301.zip)
jboss3.2.5(http://unc.dl.sourceforge.net/sourceforge/jboss/jboss-3.2.5.zip)
你可以到它的主页去找(http://www.jboss.org),(最好是用3.1x或以前的版本,因为lomboz3.01中没有高版本的server文件,配置起来比较麻烦,我这里找了一个jboss325.server)。
二、千里之行始于足下
接下来开始安装上面下载的这些工具:
1、安装jdk(个人建议安装的路径中不要有空格,免得将来使用其他开发工具如weblogic时出现问题)我是安装在d:/java/jdk1.5.0
2、安装eclipse,直接解压,把你需要用的组件都解压到对应目录下(3.01已有中文包,方便觉得e文读着比较烦的朋友看帮助文件)。
3、解压lomboz3.01到eclipse/plugins
4、解压jboss3.25到d盘下,d:/jboss-3.2.5(那个盘自己定)到/bin下点击run.bat启动,打开http://localhost:8080测试。
5、启动eclipse,进入后如果发现lomboz的图标
,ok。没发现的自己重新导入一次lomboz(这里不再赘述)。在窗口--定制试图--快捷方式--子菜单--新建,可以选择把lomboz j2ee wizards选中,方便我们创建工程以及一些模块:
6、打开窗口--首选项--选中lomboz,把jdk tools jar的路径设为绝对路径(我这里是)D:\Java\jdk1.5.0\lib\tools.jar,如图:
这里我们顺便设置一下新建项目的路径,上图中点击展开java--构建项目,把右边的源和输入文件夹的输入改成“文件夹”模式,这样创建了新的项目后我们就可以得到/bin和/src两个文件夹分别放置编译后的文件和源代码。如图:
7、展开lomboz--server definitions,选择server typys为jboss3.2.5(在这之前要把jboss325.server复制到eclipse\plugins\com.objectlearn.jdt.j2ee_3.0.1\servers下)
jboss325.server
<serverDefinition
name="JBOSS 3.2.5"
ejbModules="true"
webModules="true"
earModules="true">
<property id="serverRootDirectory"
label="Application Server Directory:"
type="directory"
default="D:/jboss-3.2.5" />
<property id="serverAddress"
label="Address:"
type="string"
default="127.0.0.1" />
<property id="serverPort"
label="Port:"
type="string"
default="8080" />
<property id="serverConfig"
label="Server Configuration (minimal/default/all):"
type="string"
default="default" />
<property id="classPathVariableName"
label="Classpath Variable Name:"
type="string"
default="JBOSS325" />
<property id="classPath"
label="Classpath Variable:"
type="directory"
default="D:/jboss-3.2.5" />
<serverHome>${serverRootDirectory}</serverHome>
<webModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</webModulesDeployDirectory>
<ejbModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</ejbModulesDeployDirectory>
<earModulesDeployDirectory>${serverRootDirectory}/server/${serverConfig}/deploy</earModulesDeployDirectory>
<jndiInitialContextFactory>org.jnp.interfaces.NamingContextFactory</jndiInitialContextFactory>
<jndiProviderUrl>jnp://${serverAddress}:1099</jndiProviderUrl>
<startClass>org.jboss.Main</startClass>
<startWorkingDirectory>${serverRootDirectory}/bin</startWorkingDirectory>
<startVmParameters></startVmParameters>
<startProgramArguments>-c ${serverConfig}</startProgramArguments>
<stopClass>org.jboss.Shutdown</stopClass>
<stopWorkingDirectory>${serverRootDirectory}/bin</stopWorkingDirectory>
<stopVmParameters></stopVmParameters>
<stopProgramArguments>-S</stopProgramArguments>
<serverClassPath>
<jar type="variable">JDK_TOOLS</jar>
<jar type="variable">${classPathVariableName}/bin/run.jar</jar>
<jar type="variable">${classPathVariableName}/bin/shutdown.jar</jar>
<jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar</jar>
<jar type="variable">${classPathVariableName}/lib/concurrent.jar</jar>
<jar type="variable">${classPathVariableName}/lib/jboss-system.jar</jar>
<jar type="variable">${classPathVariableName}/lib/dom4j.jar</jar>
<jar type="variable">${classPathVariableName}/lib/xercesImpl.jar</jar>
<jar type="variable">${classPathVariableName}/lib/xml-apis.jar</jar>
<jar type="variable">${classPathVariableName}/lib/gnu-regexp.jar</jar>
<jar type="variable">${classPathVariableName}/lib/getopt.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/deploy/jbossweb-tomcat50.sar/servlet-api.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/bcel.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss-transaction.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jnpserver.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-pattern.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-util.jar</jar>
</serverClassPath>
<clientClassPath>
<jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar</jar>
<jar type="variable">${classPathVariableName}/client/jboss-client.jar</jar>
<jar type="variable">${classPathVariableName}/client/jboss-common-client.jar</jar>
<jar type="variable">${classPathVariableName}/client/jboss-jaas.jar</jar>
<jar type="variable">${classPathVariableName}/client/jbosssx-client.jar</jar>
<jar type="variable">${classPathVariableName}/client/jnet.jar</jar>
<jar type="variable">${classPathVariableName}/client/jnp-client.jar</jar>
<jar type="variable">${classPathVariableName}/client/log4j.jar</jar>
<jar type="variable">${classPathVariableName}/server/default/lib/jnpserver.jar</jar>
</clientClassPath>
<projectClassPath>
<jar type="variable">JDK_TOOLS</jar>
<jar type="variable">${classPathVariableName}/bin/run.jar</jar>
<jar type="variable">${classPathVariableName}/bin/shutdown.jar</jar>
<jar type="variable">${classPathVariableName}/client/jboss-j2ee.jar</jar>
<jar type="variable">${classPathVariableName}/lib/concurrent.jar</jar>
<jar type="variable">${classPathVariableName}/lib/jboss-system.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/deploy/jbossweb-tomcat50.sar/servlet-api.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/bcel.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jboss-transaction.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jnpserver.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-pattern.jar</jar>
<jar type="variable">${classPathVariableName}/server/${serverConfig}/lib/jpl-util.jar</jar>
</projectClassPath>
<adminTool>
<web><deploy /><undeploy />
</web>
<ejb><deploy /><undeploy />
</ejb>
<ear><deploy /><undeploy />
<webModule><deploy /><undeploy />
</webModule>
<ejbModule><deploy /><undeploy />
</ejbModule>
</ear>
</adminTool>
<adminToolPath>
</adminToolPath>
</serverDefinition>
jboss设置如图,
8、点击“应用”。确定。
ok,理论上现在我们已经把j2ee的平台搭建好了。下面我们将进行“hello world”的测试。