• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to Setup GlassFish in Ubuntu

1027

To Setup GlassFish 4.1 in Ubuntu

GlassFish server is a free-ware, light weight application server for the development and deployment of Java Platform and web technologies based on Java technology. It supports
different Java based technologies. Installation of Glassfish in Ubuntu is explained in this manual.

To install dependency

Run the following command to install the dependency packages that are necessary for installing java.

root@linuxhelp:/home/user1# apt-get install python-software-properties 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Setting up python-apt (1.1.0~beta1build1) ...
Setting up python-pycurl (7.43.0-1ubuntu1) ...
Setting up python-software-properties (0.96.20.4) ...


Add the PPA for installing Java by running the following command.

root@linuxhelp:/home/user1# add-apt-repository ppa:webupd8team/java 
 Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK7 / JDK8 / JDK9). There are no actual Java files in this PPA.
.
.
.
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK


After adding the PPA repository, use the following command to update the services.

root@linuxhelp:/home/user1# apt-get update 
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease   
Get:2 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial InRelease [17.6 kB]
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease                           
Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease                   
Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease     
Get:6 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main amd64 Packages [2,840 B]
Get:7 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main i386 Packages [2,840 B]
Get:8 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main Translation-en [1,260 B]
Fetched 24.5 kB in 1s (16.2 kB/s)
Reading package lists... Done


Run the following command to install the oracle packages.

root@linuxhelp:/home/user1# apt-get install oracle-java8-installer 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
.
Oracle JDK 8 installed
update-alternatives: using /usr/lib/jvm/java-8-oracle/jre/lib/amd64/libnpjp2.so to provide /usr/lib/mozilla/plugins/libjavaplugin.so (mozilla-javaplugin.so) in auto mode
Oracle JRE 8 browser plugin installed
Setting up gsfonts-x11 (0.24) ...


Once the installation is done, Set the environment variable " JAVA_HOME" as the path of the newly installed Oracle JDK 8. To do so, open and /etc/environment file and add the following lines into it.

root@linuxhelp:/home/user1# nano /etc/environment 
JAVA_HOME=" /usr/lib/jvm/java-8-oracle" 

Save and exit the file.
Then reload the file.

root@linuxhelp:/home/user1# source /etc/environment 


Run the following command to check the java version.

root@linuxhelp:/home/user1# java -version 
java version " 1.8.0_101" 
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

To install GlassFish

First download the glassfish server package and change the directory to temp.

root@linuxhelp:/home/user1# cd /tmp/
root@linuxhelp:/tmp# wget http://download.java.net/glassfish/4.1/release/glassfish-4.1.zip 
--2016-09-17 00:19:29--  http://download.java.net/glassfish/4.1/release/glassfish-4.1.zip
Resolving download.java.net (download.java.net)... 96.17.182.42, 96.17.182.49
&hellip 
&hellip 
2016-09-17 00:25:25 (297 KB/s) - ‘ glassfish-4.1.zip’  saved [107743725/107743725]


Now extract the package into the /opt/ directory by using the following command.

root@linuxhelp:/tmp# unzip glassfish-4.1.zip -d /opt/ 
Archive:  glassfish-4.1.zip
   creating: /opt/glassfish4/
   creating: /opt/glassfish4/bin/
  inflating: /opt/glassfish4/bin/asadmin  
&hellip 
&hellip 
&hellip 
  inflating: /opt/glassfish4/pkg/lib/pkg-bootstub.bat  
  inflating: /opt/glassfish4/pkg/lib/pkg-bootstub.sh  
  inflating: /opt/glassfish4/pkg/lib/pkg-client.jar  


To setup PATH variable for GlassFish, open and edit the " ~/.profile" file as shown below.

root@linuxhelp:/tmp# nano ~/.profile  
export PATH=/opt/glassfish4/bin:$PATH


Reload the file by using the following command.

root@linuxhelp:/tmp# source ~/.profile 

To launch GlassFish

Run the following command to start the GlassFish server.

root@linuxhelp:/tmp# asadmin start-domain 
Waiting for domain1 to start ...................
Successfully started the domain : domain1
domain  Location: /opt/glassfish4/glassfish/domains/domain1
Log File: /opt/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.


Open the browser and point the URL http://< ip-address:8080> / to check the homepage of GlassFish Server
GlassFish_Server


Now to set the password for the application by using the following command.

root@linuxhelp:/tmp# asadmin change-admin-password 
Enter admin user name [default: admin]> admin
Enter the admin password>  
Enter the new admin password>  
Enter the new admin password again>  
Command change-admin-password executed successfully.


To access the administration panel remotely, use the following command.

root@linuxhelp:/tmp# asadmin enable-secure-admin 
Enter admin user name>   admin
Enter admin password for user " admin" >  
You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.


After setting the administrative panel, restart the domain.

root@linuxhelp:/tmp# asadmin restart-domain 
Successfully restarted the domain
Command restart-domain executed successfully.


Now open the browser and point to http://ip-address:4848 and enter the user credentials to login remotely.
Open_Browser
GlassFish_Console

To deploy an application

To deploy a WAR application into the GlasFish, download hello.war from the glassfsh official page by running the following command.

root@linuxhelp:/tmp# wget https://glassfish.java.net/downloads/quickstart/hello.war 
--2016-09-17 00:36:54--  https://glassfish.java.net/downloads/quickstart/hello.war
Resolving glassfish.java.net (glassfish.java.net)... 137.254.56.48
&hellip 
&hellip 
2016-09-17 00:36:56 (13.7 KB/s) - ‘ hello.war’  saved [4102/4102]


Once the download is completed, deploy it using asadmin command.

root@linuxhelp:/tmp# asadmin deploy hello.war  
Enter admin user name>   admin
Enter admin password for user " admin" >  
Application deployed with name hello.
Command deploy executed successfully.


Open the browser and navigate to http://ip-address:8080/hello
navigate_browser

If you are tired of entering the username and password everytime you deploy or undeploy an application, you can simply create a file named pwdfile with a text editor and add the following lines into it.

root@linuxhelp:/tmp# nano pwdfile 
AS_ADMIN_PASSWORD=your_admin_password

Save the file and exit

To undeploy the application

To stop the running application, use the following command.

root@linuxhelp:/tmp# asadmin undeploy hello 
Enter admin user name>   admin
Enter admin password for user " admin" >  
Command undeploy executed successfully.


we can just add --passwordfile flag pointing the pwdfile and then deploy the war application to deploy the application without entering the username and password

root@linuxhelp:/tmp# asadmin --passwordfile pwdfile deploy hello.war 
Application deployed with name hello.
Command deploy executed successfully.

Tags:
liam
Author: 

Comments ( 1 )

dkerrh
Is there Any Update here to further Glassfish Install, Given that It worked and now we have the return "GlassFish requires Java SE version 6. Your JDK is version 0"
Any Help would be great
Add a comment

Frequently asked questions ( 5 )

Q

When Glassfish application should be restarted?

A

When Glassfish application should be restarted? Whenever you deploy your hosting application, you should restart your Glassfish application.

Q

Is there any Alternative for Glassfish?

A

Such as,
JBoss,
appserver.io,
Webshare Application Server,
Jonas,
Mako Server

Q

How to start/stop/restart the Glassfish application?

A

Follow the below steps to start/stop the glassfish application.

Step 1: Login to your NGASI panel.

Step 2: Now click the Start/Stop menu in the home page.

Q

Who are the members of the tutorial team?

A

For information about the authors, read Appendix C, "About the Authors".

Q

What platforms does The Java EE 5 Tutorial support?

A

For a list of supported platforms, see the Application Server Release Notes.

Related Tutorials in How to Setup GlassFish in Ubuntu

Related Tutorials in How to Setup GlassFish in Ubuntu

How to Setup GlassFish in Ubuntu
How to Setup GlassFish in Ubuntu
Oct 5, 2016
How to install Jenkins in Linux
How to install Jenkins in Linux
Jul 6, 2016
How to Manage Jenkins in Linux
How to Manage Jenkins in Linux
Jul 6, 2016
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help legeek ?
Installation of the call center module

hello

I wish to install a call center in virtual with issabel, I downloaded the latest version of it , but I don' t arrive to install the call center module in issabel. please help me

thanks!

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.