# Howto: Installing JOnAS from scratch

This guide provides instructions for installing JOnAS from scratch on Unix-compatible systems.

The content is organized into the following steps

1. J2SE SDK 1.4 installation
2. Ant 1.6 installation
3. Tomcat 5.5.x installation
4. Jetty 5.1.x installation
5. JOnAS installation
6. Setup

## J2SE SDK 1.4 installation

Download the binary version of 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.x-bin.tar.bz2`
(or `unzip apache-ant-1.6.x-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.x.tar.gz` from the Jakarta web site and install bcel-5.x.jar in the directory `$ANT_HOME/lib.`

## Tomcat 5.5.x installation

Download the binary version of Tomcat 5.5.x from the Jakarta Tomcat web site. Untar it into the appropriate directory:

`tar -xvf jakarta-tomcat-5.5.x.tar.gz`

Set the CATALINA_HOME environment variable:

`export CATALINA_HOME=<Installation Directory>`
JONAS_BASE directory can be used as CATALINA_BASE: `export CATALINA_BASE=$JONAS_BASE`
Configuration information for the Realm and users is provided at the Setup process.

## Jetty 5.1.x installation

Download the binary version of Jetty 5.1.x from the Jetty web site. Untar it into the appropriate directory:

`tar -xvf jetty-5.1.x-all.tar.gz`

Set the JETTY_HOME environment variable:

`export JETTY_HOME=<Installation Directory>`

## JOnAS installation

Download the binary version of JOnAS from the ObjectWeb 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 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 is to be installed and untar this file, using
the `tar -zxvf jonas.tgz` command.
After installing the JOnAS product, set the following environment variable:

`export JONAS_ROOT = <Installation Directory>
PATH = $JONAS_ROOT/bin/unix:$PATH`

Do an `ant install` in the `JONAS_ROOT` directory to unpack the jar files necessary to build `jonas.jar` and `client.jar`.

## Setup

Before using JOnAS, the following setup activities must be completed:

- 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.
- JONAS_BASE directory can be used as CATALINA_BASE: `export CATALINA_BASE=$JONAS_BASE` so it will use the JOnAS realms.
- If required, configure the Mail service (for PetStore or the example mailsb for instance). 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`

Compile the examples as follows:
`ant install` in the directory `$JONAS_ROOT/examples`