Glassfish V3 Installation on Linux (for beginners…)

Hi there,

sometimes we just need to intall a new server on a new virtual machine or at the start of a new project.

Here I wil just try to redefine the steps to install and configure a Glassfish V3 server on a Linux machine. Just afer that we will probably need to install a complete continuous platform of integration (with a Nexus or Archiva, a Hudson or continuum, Maven, Sonar, .., …) but it’s another subject. So maybe for a future post smiley


Well, let’s start by reminding what needs a Glassfish to run: a JDK.

In our case, we will first install a JDK6, so let’s begin with that.


1.Installation of the JDK6


URL of the JDK 6 :

The file should be called : « jdk-6u20-linux-i586-rpm.bin » (in the case of the version 20 of the JDK 6)

Juste paste the file in the directory /usr/java. If this directory does not exists, create it.



To install the JDK, move into the /usr/java directory and launch the following commands :

chmod 755 jdk-6u20-linux-i586-rpm.bin


that’s all :)


To check the correct installation of the JDK6, move into the /usr/java/jdk1.6.0_20 directory and launch :

/usr/java/jdk1.6.0_20/bin/java -version

You should see a message like this one:


java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)



We will now export 2 variables which will point to the Java and Glassfish installation directory (Glassfish will be installed on the next chapter).

Open or create the etc/profile file.

Insert the following lines at the beginning of the file :

export JAVA_HOME=/usr/java/jdk1.6.0_20

export GLASSFISH_HOME=/usr/glassfishv3/glassfish



1.5.update your profile

To immediately update our profile without having to disconnect and reconnect yourself, just enter the command :

source /etc/profile


2.Installation of Glassfish Server V3

Ok, now we are ready to install and use Glassfish, so we will first began by downloading the latest version.


URL of Glassfish V3 :

The direct URL : « »



On Linux (with a X environment) the installation is very easy and we just need to launch the setup (like in a Windows or MacOs world).

  • Create the destination directory by the following command : mkdir /usr/glassfishv3
  • move the installation file previously downloaded in the new directory
  • Launch the next line to start the installation :
    sh ./

This last command will launch the installation wizard and will create a “glassfish” directory into the /usr/glassfishv3 directory.

Let the default values during the installation (only the installation directory and the admin password should be changed).


3.Deployment of an application (a WAR file) in Glassfish V3

You can deploy a WAR in Glassfish by several ways :

  • copy the WAR directly into the domain-dir/autodeploy/ directory (my be just in development environment, cause of the performance issues)
  • Use the Glassfish’ admin console
  • Use Ant script
  • Use asadmin script
  • Use an EDI (Eclipse, NetBeans, …)

3.1Deploy with the admin console

  • To launch the admin console, be first sure that the Glassfish server is running (/usr/glassfishv3/glassfish/bin/startserv).
    Then launch the web page at the following URL : http://localhost:4848
  • Open the node « Application ».
  • Clik on the « Deploy » button.
  • Select the option “Package file to be uploaded to the Application Server.”
  • Select thefull adress of the WAR file and then click on the OK button.
  • Click on Next.
  • Enter the name of the application.
  • Enter the Context-Root.
  • Select the checkbox “Enabled”.
  • Click on “End”.


3.2Deploy with asadmin

To deploy a WAR with asadmin, open a terminal and launch the command :

asadmin deploy full-path-to-war-file


3.3Deploy with Ant


To deploy a WAR with Ant, open a terminal on the directory containing the war file and launch the command :

ant deploy



Here is where to download the needed files :


Here is the official documentation :


I hope this post could help at least someone :)

Feel free to ask me questions about the deployment or other questions related to the deployment and continuous integration.

    • harsono
    • March 19th, 2012 7:04am

    Hi Codeartex

    Thank very much this help fully for me ^..^


      • BobK
      • May 18th, 2012 11:06pm

      Thank you so much. That was clear and to the point. Worked great for me and I was up and running in under and hour.

      Would be great to see a similar quick setup for maven using eclipse or some such…

    • hooman
    • March 22nd, 2012 9:24am

    hi. a question ?

    while installing JDK in linux fedora 15 , i encounterred with this error , what’s wrong with it ?
    i’m new in linunx and running it on vmware 8 . i did what exactly you instructed but the following error shown :

    error: open of sun-javadb-common-10.6.2-1.1.i386.rpm failed: No such file or directory
    error: open of sun-javadb-core-10.6.2-1.1.i386.rpm failed: No such file or directory
    error: open of sun-javadb-client-10.6.2-1.1.i386.rpm failed: No such file or directory
    error: open of sun-javadb-demo-10.6.2-1.1.i386.rpm failed: No such file or directory
    error: open of sun-javadb-docs-10.6.2-1.1.i386.rpm failed: No such file or directory
    error: open of sun-javadb-javadoc-10.6.2-1.1.i386.rpm failed: No such file or directory

    Thanks for help in advance

    • Hi Hooman,

      Did you try to install the JDK with sudo?

      You can also try the following command to extract the files:
      sh jdk-6u31-linux-i586-rpm.bin -x
      and then:
      sudo rpm -ivh jdk-6u31-linux-i586.rpm

      • Nick Fenwick
      • June 4th, 2012 12:31pm

      To get around the “permission denied” problems while installing, even as root, have a look at the directory you’re in and its mount settings. e.g. my /downloads folder is actually a symlink to a folder in a mounted ext4 partition and I cannot run some installers directly from it, probably because of the ‘nosuid’ or ‘noexec’ flags on the mount point.

      [root@uberneek tmp]# ls -l /downloads/jdk-6u32-linux-i586-rpm.bin
      -rwxrwxr-x. 1 root root 68593311 Jun 4 19:21 /downloads/jdk-6u32-linux-i586-rpm.bin

      [root@uberneek tmp]# ls -l /downloads
      lrwxrwxrwx. 1 root root 15 Apr 6 15:09 /downloads -> /data/downloads

      /dev/sda3 on /data type ext4 (rw,nosuid,nodev,noexec,relatime,seclabel,user_xattr,acl,barrier=1,data=ordered)

      Copy or move your JDK rpm.bin file to another location such as /tmp and try again.

      Googling turned up this solution from 2005:

    • IngenStrul
    • March 25th, 2012 6:26pm

    This post certainly helped me…a lot! Thanks!

    • IngenStrul
    • March 27th, 2012 7:29am

    Hi again Gwennael,
    A couple of days ago, i used your instructions to install glassfish on a old pc, it worked great. Since i’m a newbie to linux (debian), i wanted to test local first before ordering a VPS. I’m now trying to install mysql administrator and glassfish on a server machine, but i only have a shell.

    Is there a smooth way to install a vlc / teamviewer like solution, so i can login and do things in the gui? I’ve installed a desktop package, but i’m not sure about the X environment. I spent quite some time to read and fix ssh tunnel stuff, but no succes yet. Please help, or maybe you know some good documentation. I’m running Debian Squeeze. Thanks in advance.

    • IngenStrul
    • March 27th, 2012 10:30am

    Update: i managed to configure a vnc viewer/server and am looking at my linux desktop as we speak :)
    This page was very helpful:

  1. Hi IngenStrul,

    thanks for the link. I think it can help a lot of people :)

    • Pawel Huszcza
    • July 2nd, 2012 8:25pm

    Thank You for Your Tutorial – really great and it works but… for me only until authentication step unfortunately. When I am prompted to enter admin port, http port (default values are there already = 4848, 8080) I leave the default values as instructed in Your tutorial, then there is user name and password. When I click next, this is what I get:

    [Admin Port]*[{0} {1}]: Host name not found
    [HTTP Port]*[{0} {1}]: Host name not found

    Sorry I am not very experienced with linux and the only “help” I can get on-line, is something that maybe I should use hostname and domainname commands. I did it with no idea what for. The result was: hostname = dv7 and (none) for domainname.

    WHAT DO I HAVE TO DO ????? I am really lost.

  2. Hi Pawel,

    I suggest you create a new domain with its own ports.
    You can easily achieve this on a command line (from the ‘bin’ folder of glassfish):

    asadmin create-domain –user admin –portbase 3000 –savemasterpassword=true myNewDomain

    where ‘myNewDomain” is the name of you domain and the “–portbase 3000″ command specifies that all ports will begin by “30″ : 3048 for admin, 3080 for the webapps, …
    You can change 3000 by any number you want, but be careful not to be out of the range of authorized ports and to not choose an already used one.

    When typing this command, Glassfish will print the new ports for this new domain on the console, so don’t worry to get them :)

    Hope this will help.

    • Pawel Huszcza
    • July 2nd, 2012 9:35pm

    Thank You so much just one more point on that: I do not have a bin folder because installation has failed due to the problem described previously. It was just after accepting terms and conditions. The only thing that I have in the installation directory is: file, so no bin folder as well.

    • Pawel Huszcza
    • July 3rd, 2012 10:01am

    I do not have a bin folder because installation has failed due to the problem described previously. It was just after accepting terms and conditions. The only thing that I have in the installation directory is: file, so no bin folder as well. What does it mean ?

    • gu
    • August 23rd, 2012 4:48pm

    The glassfish package is not available in that link, now is at

  3. I have to thank you for the efforts you have put in writing this site. I am hoping to see the same high-grade content by you in the future as well. In fact, your creative writing abilities has motivated me to get my very own blog now ;)

    • Xavier Cale
    • May 23rd, 2013 7:51pm

    If you have the “host name not found” problem on glassfish installation. Make the following:

    1) In a console, press hostname command to view your current hostname.
    2) Add your host tame to the /etc/hosts file yourhostname
    3) Try again (it is not necessary restart)

    • Hi,

      thank you for your tips.
      And sorry for the delay to accept your post, it was lost between 91 russian spams (!) :(

  1. No trackbacks yet.