# Howto: Installing the packaging JOnAS with a web container
(JOnAS/Tomcat or JOnAS/Jetty) from scratch

This guide provides instructions for installing JOnAS (with a web container already included) from scratch.

The content is organized into the following steps:

1. J2SE SDK 1.4 installation
2. ANT 1.6 installation
3. JOnAS/ Web Container installation
4. Setup
5. Starting JOnAS and running examples

## J2SE SDK 1.4 installation

Download the binary version of a J2SE SDK 1.4 from the java Sun web site into the appropriate directory. Launch the executable file:

`./j2sdk-1_<version number>-<system>.bin` for Unix
`./j2sdk-1_<version number>-<system>.sh` for Linux
`j2sdk-1_<version number>-windows-i586.exe` for Windows

Set the JAVA_HOME environment variable and update the path:

`export JAVA_HOME=<Installation Directory>
PATH=$JAVA_HOME/bin:$PATH (on Windows : PATH=%JAVA_HOME%/bin;%PATH%)`

## ANT 1.6 installation

Download the binary version of Ant 1.6 from the Ant Apache web site. Untar or Unzip it into the appropriate directory:

`tar -jxvf apache-ant-1.6.1-bin.tar.bz2`
(or `unzip apache-ant-1.6.1-bin.zip`)

Set the ANT_HOME environment variable and update the path:

`export ANT_HOME=<Installation Directory>
PATH=$PATH;$ANT_HOME/bin (on Windows : PATH=%ANT_HOME%/bin;%PATH%)`

Download `bcel-5.1.tar.gz` from the Jakarta web site and install bcel-5.1.jar in the directory `$ANT_HOME/lib.`

## JOnAS/Web Container installation

Download the binary version of JOnAS with Tomcat or Jetty from the ObjectWeb forge web site.
Choose a location for the JOnAS installation.
Be aware that if you have already installed a previous version of JOnAS in this location, the new installation will overwrite the existing files, thus customized configuration files may be lost. Therefore, it is prudent to save these files before starting the installation process.
The installation process consists of untaring the downloaded file.
Change to the directory in which JOnAS will be installed and untar this file, using
the `tar -zxvf jonas.tgz` command. Note that this file can be opened with winzip on Windows.
After installing the JOnAS product, set the following environment variable:

`export JONAS_ROOT = <Installation Directory>
PATH = $JONAS_ROOT/bin/unix:$PATH (on Windows: PATH=%JONAS_ROOT%/bin/nt;%PATH%)`

## Setup

Before using JOnAS, complete the following setup activities:

- If a `CATALINA_HOME` or `CATALINA_BASE` or `JETTY_HOME` environment variable has already been set, it should be unset. JOnAS will set these variables, without requiring any modifications.
- Based on the data source being used, create a file `<data source>.properties` (templates are located in the directory `$JONAS_ROOT/conf`). Then add the data source file name (without the extension `.properties`) to the `jonas.properties` file:
  `jonas.service.dbm.datasource <data source>`
  Add the JDBC driver in `$JONAS_ROOT/lib/ext` or in `$JONAS_BASE/lib/ext` directory.
- If required, configure the Mail service (for PetStore or the example mailsb, for example). JOnAS provides two types of mail factories: `javax.mail.Session` and `javax.mail.internet.MimePartDataSource`. Two types of files that can be adapted to fit your installation are located in the directory `$JONAS_ROOT/conf`: `MailSession1.properties` and `MailMimePartDS1.properties`. Then, in the `jonas.properties` file, define the `jonas.service.mail.factories` property:
  `jonas.service.mail.factories MailSession1,MailMimePartDS1`

## Starting JOnAS and running some examples

If the Setup step has not been completed as described, JOnAS may not work.
Use the command `jonas check` to verify that the environment is correct.

If the environment is correct, JOnAS is ready to use.
Do a `jonas start`, then use a browser to go http://localhost:9000/. (Modify this url with the appropriate hostname.)
From the root context in which JOnAS was deployed, you can execute the earsample, access the JOnAS administration application, as well as perform other functions.