以下代码打包方法未尝试,有兴趣的可以试下,可以在评论告知
具体如何打包,可以使用许多开发工具的IDE环境,如Eclipse、NetBeans、ant、JBuilder等。也可以用cmd
命令:jar -cvfapplicationname.war package.*;
甚至可以在程序执行中打包:
try{
string strjavahome =system.getproperty("java.home");
strjavahome =
strjavahome.substring(0,strjavahome.lastindexof(\\))+"\\bin\\";
runtime.getruntime().exec("cmd /c start"+strjavahome+"jar cvf hello.war
c:\\tomcat5.0\\webapps\\root\\*");
}
catch(exception e){system.out.println(e);}
webapps这个默认的应用目录也是可以改变。打开Tomcat的conf目录下的server.xml文件,找到下面内容:
<Host name="localhost"debug="0" appBase="webapps" unpackWARs="true"
autoDeloy="true"xmlValidation="falase" xmlNamespaceAware="false">