public class ASimpleHelloObject { public static void main(String[] args) { System.out.println("ASimpleHelloObject.main was called"); } }
运行ant 显示结果如下: c:apache-ant-1.5.2samples> antBuildfile: build.xml Init : AsimpleHelloObject: [echo] Wrote AsimpleHelloObject.java compile: [javac] Compiling 1 source file to c:apache-ant-1.5.2samples run : [java] AsimpleHelloObject.main was called[echo] Ant appears to be successfully installed BUILDE SUCCESSFUL Total time :11 seconds. 到此你安装的ANT以及环境已经设置成功。如果有以下警告 Warning: JAVA_HOME environment variable is not set. If build fails because sun.* classes could not be found you will need to set the JAVA_HOME environment variable to the installation Directory of java. 表示你需要设置JAVA_HOME环境,指定你安装的JDK 目录。如何运用Ant 中的各种命令,我会在以后编写《ANT文档》介绍。
5、安装JBOSS 1) 在安装和运行JBoss 之前,你必须检查是否安装了JDK,需要在PATH环境中,设置JDK的目录。 2)、 下载JBoss 服务器。JBoss 是一个压缩文件,你可以下载最新版本。为了能支持Web Server,我用的是Windows平台,所以下载了jboss3.0.6-tomcat4.1.18。你可以到http://prdownloads.sourceforge.net/jboss/ 中直接下载。如果你使用的是Unix/Lunix平台也可以从这个网址下载相应的JBoss 服务器。 3)、安装 (1) Lunix/Unix下安装 a、 你下载了对于Unix/Lunix版本的JBoss 服务器l 用JDK 的JAR工具来解压文件到一个临时目录。 b、 设置JBOSS_DIST指向JBoss 解压后最顶级目录。 c、 然后到此目录下, cd JBOSS_DIST/bin sh run.shl 运行完后显示信息如下: bash-2.04$ /bin/sh run.sh JBOSS_CLASSPATH=:run.jar:../lib/crimson.jar jboss.home = /tmp/JBoss-2.2.2 Using JAAS LoginConfig: file:/tmp/JBoss-2.2.2/conf/default/auth.conf Using configuration "default" [Info] Java version: 1.3.1,Sun Microsystems Inc. [Info] Java VM: Java HotSpot(TM) Server VM 1.3.1-b24,Sun Microsystems Inc. [Info] System: Linux 2.2.16-22,i386 [Shutdown] Shutdown hook added [Service Control] Registered with server [Service Control] Initializing 24 MBeans ... [Service Control] Started 24 services [Default] JBoss 2.2.2 Started in 0m:7s
(2) Windows下安装 a、 下载jboss3.0.6-tomcat4.1.18.zip, 然后用WinZip解压到一个目录,我解压在c:jboss3.0.6-tomcat4.1.18目录 b、 解压后基本上不需要配置,运用bin目录下的run.bat命令。 c、 运行run.bat命令,请看后台有没有什么异常抛出。 d、 运行成功请访问http://localhost:8083将会出现空白页。访问http://localhost:8080将会出现Tomcat的欢迎页面,如果出现Apache Tomcat/4.1.12 - HTTP Status 500 - No Context configured to process this request的错误,这是正常的,因为你还没有发布.ear或.war应用。当然jboss-3.2.ORC3_tomcat-4.1.18.zip不会出现这样的问题,因为在目录serverdefaultdeploy中自带了web测试文件weBTest.ear 访问http://localhost:8082你可以看到Jboss起动的服务。你可以运行http://localhost:8080/jmx-console就会出现相关页面。
(3) Window NT 和2000补充 对于NT和Win2k系统如果你要安装NT或Win2k服务的话,可以把jboss加在系统服务中,避免你每次需要到jboss目录下运行run.bat命令,只是当系统启动时,自动启动jboss服务器。 a、 首先你需要下载javaservice.exe文件。l 编辑一个批处理文件,自己命名文件名,存入和JavaService.exe相同的目录。我命名为Jboss_Tomcat_Service.bat此文件的内容@echo offecho -------- echo Usage: %0 jdk_home tomcat_home (classic/hotspot/server)echo NOTE: You MAY NOT use spaces in the path names. If you know howecho to fix this, please tell me.echo JDK 1.4 does not come with hotpot server by default, you mustecho install this seperately if you wish to use it.echo Example: %0 ..jdk ..jboss30 hotspot echo -------- if "%1" == "uninstall" goto uninstall if "%1" == "-uninstall" goto uninstall if "%1" == "" goto usage if "%2" == "" goto usage if "%3" == "" goto usage if "%1" == "-help" goto usage if "%1" == "-?" goto usage if "%1" == "/?" goto usage :install JavaService.exe -install JBoss306 %1jrein/%3jvm.dll -Djava.class.path=%1lib ools.jar;%2in un.jar -start org.jboss.Main -stop org.jboss.Main -method systemExit -out %2inout.txt -current %2in goto eof :uninstall JavaService.exe -uninstall JBoss306 goto eof :usage echo -------- To Install JBoss 3.0.6 do echo Usage: %0 jdk_home jboss_home (classic/hotspot/server) echo NOTE: You MAY NOT use spaces in the path names. If you know how echo to fix this, please tell me. echo JDK 1.4 does not come with hotpot server by default, you must echo install this seperately if you wish to use it. echo Example: %0 ..jdk ..jboss30 hotspot echo -------- echo -------- To Uninstall JBoss 3.0.6 do echo Usage: %0 uninstall echo -------- goto eof :eof