1、安装glassfish服务器
下载软件包,解压。就算安装完成了。
2、glassfish服务的启动和关闭
进入解压目录的Bin目录下,运行以下命令,以启动glassfish服务:
./asadminstart-domain
关闭glassfish服务:
./asadmin stop-domain
这实际上是启动和关闭默认的“域”:“domain1”
这个命令列出当前启动的域:
./asadmin list-domains
3、部署网站
./asadmin deploy war-name
war-name 为glassfish应用程序的war包。
也可以直接部署网站目录:
./asadmin deploy --name hello /apps/MyApp
成功部署会有以下提示:
Application deployed successfully with name hello.
Command deploy executed successfully.
列出所有已经部署的网站:
./asadminlist-applications --type web
--type条件可以不指定,这样会列出任何类型的应用
详细信息,可以参见官方文档:
https://glassfish.java.net/docs/4.0/application-deployment-guide.pdf
如果出现glassfish a full jdk (not just jre) is required错误,可按照以下步骤解决
source: http://alvinalexander.com/blog/post/java/fixing-glassfish-jdk-path-problem-solved
Find your asenv.bat file. C:\Program Files\glassfish-4.0\glassfish\config\asenv.bat
Open it in text editor and find strings like "set AS_ = blahblah"
Add this string there "set AS_JAVA=C:\Program Files\Java\jdk1.7.0_60" (print your own JDK path here). If string "set AS_JAVA= blahblah" already exists then just fix the path.