<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>
NetBeans IDE 5.5.1 目前集成了以下几种服务器
这些服务器可以直接添加在NetBeans 中运行环境下的服务器列表中。添加服务器可以通过菜单“工具”-〉“运行时”,打开“运行环境窗口”。鼠标右键选择“服务器”-〉“添加服务器”。
但是目前这种方式只能是添加本地的服务器。而通常软件开发中,真正部署程序的服务器不会是开发程序的电脑。因为,开发中频繁开启和停止电脑或者服务器很常见,但是作为测试的环境或者面向用户的环境一定要保持相对稳定。
(一)Java应用程序远程部署在服务器的通常做法:
把应用程序远程部署在服务器的做法一般是这样,以Sun application Server 9为例。
1。在NetBeans IDE中通过“生成项目”来进行编译,打包,最后会在项目的dist目录下生成包文件,比如ear, jar, war, 或者rar 文件
2。启动远程应用服务器。在本地通过浏览器访问远程应用服务器(remoteserver)的管理界面(http://remoteserver:4848).
3。输入管理员用户名和密码。Sun application Server 9 缺省的管理员用户名和密码是admin/adminadmin
4。根据应用程序类型,选择不同的类别
应用程序类型 | 包后缀名
企业应用程序 | EAR
Web 应用程序 | WAR |
EJB模块 | JAR |
连接器模块 | RAR |
5。下面以部署Web 应用程序为例,在Sun Application Server的管理界面中,选择"应用程序"下的"Web应用程序",在“要上载的文件”中输入目录及文件名,点击“下一步”
在“在部署 Web 模块(步骤 2,共 2 步)”中,点击“完成”
在“Web 应用程序”下可以可到已经部署成功的“ RemoteDeploy”项目
6。要取消项目部署,选中“RemoteDeploy”项目,点击”取消部署”按钮.
以上的远程部署都是在 NetBeans IDE开发环境之外进行,下面介绍一个方法,把远程部署的功能集成到NetBeans IDE开发环境中来,这样在NetBeans IDE中进行远程部署和取消部署,只需要几下鼠标操作,而根本不需要使用登录远程服务器的管理界面。
(二)在NetBeans IDE中通过修改build.xml实现远程部署
这个方法使用到Sun Application Server 9上的 sun-appserv-ant.jar文件,在这个jar文件中,有我们需要的asant命令集合。asant和ANT的功能相似,用来实现Java程序的编译,打包等功能,不过asant针对的是Sun Application Server 。为方便起见,在本地机器上也安装Sun Application Server 9,这样可以比较方便地找到一些需要的库文件。
1。在NetBeans IDE中创建示例项目“ RemoteDeploy”后,我们选择这个项目部署在“Sun Java System Application Server 9”上,当然,这时候,这个服务器是本地的。鼠标右键选择“ RemoteDeploy”项目-〉“属性”,在“运行”栏目下,可以查看并改变部署的服务器。
2。在本地电脑上建立一个passwordfile.txt 文件来保存远程服务器上管理员的密码,假设passwordfile.txt放在C:\Sun\AppServer9\下。passwordfile.txt文件内容如下:
AS_ADMIN_PASSWORD=adminadmin |
3。在NetBeans IDE中, 点击“文件”窗口, 打开build.xml文件。build.xml文件除了导入一个“build-impl.xml”文件外,内容基本为空。而 build-impl.xml 定义了ant所需要的几乎所有的参数和任务。通常建议开发者不要修改build-impl.xml,而把修改放在build.xml 中,并且可以利用或者覆盖build-impl.xm中已经定义好的一些任务。
下面是修改后的build.xml。去掉了原有的注释内容和build-impl.xml的导入, 重新定义了sun-appserv-deploy和sun-appserv-undeploy, 新加了两个任务“as-remote-deploy” 和“as-remote-undeploy”
xmlversion="1.0"encoding="UTF-8"?>
<!--</span><span style="COLOR: #008000">Youmayfreelyeditthisfile.Seecommentedblocksbelowfor</span><span style="COLOR: #008000">-->
<!--</span><span style="COLOR: #008000">someexamplesofhowtocustomizethebuild.</span><span style="COLOR: #008000">-->
<!--</span><span style="COLOR: #008000">(Ifyoudeleteitandreopentheprojectitwillberecreated.)</span><span style="COLOR: #008000">-->
projectname="RemoteDeploy"default="default"basedir=".">
description>Builds,tests,andrunstheprojectRemoteDeploy.description>
propertyname="sun.appserver.ant.jar"value="c:/Sun/AppServer9/lib/sun-appserv-ant.jar"/>
propertyname="admin.cli.jar"value="c:/Sun/AppServer9/lib/admin-cli.jar"/>
propertyname="admin.password.file"value="C:/Sun/AppServer9/passwordfile.txt"/>
propertyname="asinstall.dir"value="C:/Sun/AppServer9"/>
propertyname="war.ear.file"value="E:/mymodules/RemoteDeploy/dist/RemoteDeploy.war"/>
targetname="sun-taskdef">
taskdefname="sun-appserv-deploy"classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask">
classpath>
pathelementlocation="${sun.appserver.ant.jar}"/>
pathelementlocation="${admin.cli.jar}"/>
classpath>
taskdef>
taskdefname="sun-appserv-undeploy"classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask">
classpath>
pathelementlocation="${sun.appserver.ant.jar}"/>
pathelementlocation="${admin.cli.jar}"/>
classpath>
taskdef>
target>
targetname="as-remote-deploy"depends="sun-taskdef">
sun-appserv-deployfile="${war.ear.file}"
name="RemoteDeploy"
force="true"
precompilejsp="false"
verify="false"
upload="true"
user="admin"
passwordfile="${admin.password.file}"
host="remoteserver"
port="4848"
asinstalldir="${asinstall.dir}"/>
target>
targetname="as-remote-undeploy">
sun-appserv-undeploy
name="RemoteDeploy"
user="admin"
passwordfile="${admin.password.file}"
host="remoteserver"
port="4848"
asinstalldir="${asinstall.dir}"/>
target>
project>
对 sun-appserv-deploy 和 sun-appserv-undeploy 的参数解释,可以参考文档“Application Server asant Tasks ” (http://docs.sun.com/app/docs/doc/819-3659/beaep?l=zh&a=view):
4。在NetBeans 中的”文件”tab中,点开“build.xml”,可以看到任务“as-remote-deploy”和“as-remote-undeploy”,
5。启动远程服务器remoteserver上的”Sun Application Server 9”.
6。鼠标右键选择“as-remote-deploy”-〉“运行目标”,就可以把项目“RemoteDeploy”部署在远程服务器“remoteserver”上。在NetBeans IDE输出窗口中可以看到以下内容
sun-taskdef: Trying to override old definition of task sun-appserv-deploy Trying to override old definition of task sun-appserv-undeploy init: deps-module-jar: deps-ear-jar: deps-jar: library-inclusion-in-archive: library-inclusion-in-manifest: compile: compile-jsps: do-dist: dist: as-remote-deploy: Executing: deploy --user admin --passwordfile "C:\Sun\AppServer\passwordfile.txt" --host remoteserver --port 4848 --force=true --enabled=true --name RemoteDeploy --verify=false --precompilejsp=false --upload=true "E:\mymodules\RemoteDeploy\dist\RemoteDeploy.war" 已成功执行命令 deploy。 生成成功(总时间:0 秒) |
7。鼠标右键选择“as-remote-undeploy”-〉“运行目标”, 就可以从远程服务器”remoteserver”上取消项目“RemoteDeploy”的部署。在NetBeans IDE输出窗口中可以看到以下内容
as-remote-undeploy: Executing: undeploy --user admin --passwordfile "C:\Sun\AppServer\passwordfile.txt" --host remoteserver --port 4848 RemoteDeploy 已成功执行命令 undeploy。 生成成功(总时间:3 秒) |
(三)在NetBeans IDE中实现远程部署
在NetBeans 5.5.1中最简单的远程注册办法是通过“服务器管理”界面。选择菜单“工具”-〉“服务器管理器”。 点击"添加服务器".
只需要四步:
1。在“平台文件夹位置”中,选择“注册远程域”。点击“下一步”
2。输入主机名(主机名或主机IP地址)和端口号,点击“下一步”。在输入主机名的过程中,NetBeans会判断远程主机及端口是否有效。
3。输入远程主机的管理员用户名和管理员口令。点击“完成”
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1770680
相关推荐
使用NetBeansIDE在远程Web服务器上部署PHP应用程序[参照].pdf
方便 快捷 NetBeansIDE6.8 java 看了这个可以帮助你更好地使用NetBeansIDE6.8
Pro NetBeans IDE 5.5 Enterprise Edition 电子书
一款友好的集成开发软件,可以使用它来开发Java、Web、Android和其他项目。 直接新建一个Jframe项目就可以开始制作你自己的界面风格,具体的操作就是拖动你要的组件,从右边的组件面板中拖到JFrame窗体中,调节好...
NetBeans+IDE+使用说明和示例教程.pdf
NetBeans IDE 中国教育考试版 (2007) 使用说明和示例教程
NetBeans IDE 是一个开发环境 - 供程序员编写、编译、调试和部署程序的一个工具。 它是用 Java 编写的 - 但却可以支持任何编程语言。 另外也有巨大数量的模块来扩展 NetBeans IDE,它是一个免费产品,不限制其使用...
[Packt Publishing] NetBeans IDE 7 开发技巧 (英文版) [Packt Publishing] NetBeans IDE 7 Cookbook (E-Book) ☆ 图书概要:☆ Over 70 highly focused practical recipes to maximize your output with ...
NetBeans IDE开发指导,入门用的
Netbeans IDE 6高级编程 英文高清版
NetBeans+IDE开发指导,英文版的,网上的有一些打不开,这个是可以打开的。点击主页可以快速转到目录页。 NetBeans™ IDE Field Guide Developing Desktop, Web, Enterprise, and Mobile Applications By Patrick ...
使用NetBeans IDE 建立web service项目(2),请下载(1)后一起解压。
本人的原创文章,手把手地教你如何安装与使用NetBeansIDE,以6.7版为例,每步一图片。
这是NetBeans IDE工具的一些基本的使用实例,初学者可以看一看
Web services development using NetBeans IDE and GlassFish
The NetBeans IDE has seen adoption snowballing over the past years, particularly with the introduction of a completely new,rewritten, slick Java editor. You’ll find this reference card helpfulif you ...
NetBeans IDE 5.5 快速入门指南,详细介绍,很有用哦。
NetBeansIDE中连接MySQL数据库
本指南主要适用于 NetBeans IDE 5.5(以上) 的新用户,无论您是 IDE 的新手还是以前使用过不同开发环境的有经验的 IDE 用户都可以使用本指南。但是,本指南的读者应该至少具有 Java 编程语言和相关技术的基础知识。...
NetBeans IDE 8.2 所支持的技术ALL NetBeans IDE 8.2 所支持的技术ALL