To install and setup a domain in the Glassfish 2 application server. We can then use this Glassfish server for various java tutorials such as web-services, EJBs and JMS. This covers basic setup and configuration of Glassfish 2. Leave any questions or problems as comments and I will endeavour to answer them.
We assume that the jdk 1.5.0 or compatible version and Ant are already installed.
Versions used in this example
- Download the image/binary and save it to the directory where you wish to install glassfish. Example C:\Program Files\.
- Now open a command prompt and cd into the directory where you saved the file.
- Run java -jar to unpack the file. This will create a directory called glassfish.
C:\Program Files>java -jar glassfish-installer-v2.1-b60e-windows.jar
- Now cd into the glassfish directory that the previous command created.
- Run ant on the setup.xml file. I don't have ant in my path so I'm specifying the full path to my ant executable.
C:\Program Files\glassfish>D:\downloads\apache-ant-1.7.1\bin\ant -f setup.xml
- Create a directory called domains under the glassfish directory.
- Now cd into the glassfish\asadmin\bin directory,
- Run the asadmin create-domain command to create a domain for our applications. I have chosen port 8082 because on conflichs with apache's web-server and tomcat. You can put in whatever you like. This will create a domain1 directory under the domains directory.
...glassfish\bin>asadmin create-domain --adminuser admin --adminport 4848 --instanceport 8082 domain1
- Cd into the domain1\bin directory and run startserver.bat. For admin username type admin and type the passwords you entered when you created the domain.
- Check the logfiles at domain1\logs to make sure everything looks ok.
- Open a browser and go to http://127.0.0.1:8082. You should see a welcome page.
- In the browser type http://127.0.0.1:4848 and login using admin and the password you created. You are now done.
Back to the tutorial trail | Home.