1、安装Java
安装Openjdk:
$ sudo apt install openjdk-8-jdk
或者安装Oracle javajdk:Ubuntu 16.04 安装 Oracle JDK9
依次执行如下命令:
$ sudo apt install python-software-properties software-properties-common
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt update
$ sudo apt install oracle-java9-installer
查看Java版本:
$ java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
2、安装GlassFish
去https://glassfish.java.net/download.html下载最新版本的GlassFish:
$ cd /tmp
$ wget http://download.java.net/glassfish/4.1.1/release/glassfish-4.1.1.zip
解压:
$ unzip glassfish-4.1.1.zip
$ sudo mv glassfish4 /opt
启动GlassFish服务:
/opt/glassfish4/bin/asadmin start-domain
启动时遇到的错误:
There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server.
Command start-domain failed.
经过排查,并没有找到任何使用4848端口的应用。我通过编辑/etc/hosts文件添加hostname解决。
3、访问GlassFish
GlassFish使用的默认端口是8080;管理员服务端口是4848,用户名admin,密码为空。
http://your_ip_or_domain:8080:
http://your_ip_or_domain:4848:
GlassFish文档:https://glassfish.java.net/documentation.html