# Installing JOnAS from scratch

This guide presents the different points of an installation of JOnAS from scratch on Unix-like systems.

The different steps are

1. Installation of the JDK 1.4
2. Installation of ant 1.5
3. Installation of Tomcat 4.0.x
4. Installation of JOnAS
5. Setup

## Installation of the JDK 1.4

Dowload the binary version of JDK 1.4 at the Sun web site in the directory into which you want to install it. Launch the executable file :

`./j2sdk-1_4_0_<version number>-<system>.bin` for Unix
`./j2sdk-1_4_0_<version number>-<system>.sh` for Linux

Set the JAVA_HOME environment variable and update the path :

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

## Installation of ant 1.5

Download the binary version of ant 1.5 at the Apache web site. Untar it in the directory into which you want to install it :

`tar -xvf jakarta-ant-1.5.1-bin.tar.bz2`

Set the ANT_HOME environment variable and update the path :

`export ANT_HOME=<Installation Directory>
PATH=$PATH;$ANT_HOME/bin`

Download bcel.jar from the Jakarta web site and install it in the directory $ANT_HOME/lib

## Installation of Tomcat 4.1.x

Download the binary version of Tomcat 4.1.x at the Jakarta Tomcat web site. Untar it in the directory into which you want to install it :

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

Set the CATALINA_HOME environment variable :

`export CATALINA_HOME=<Installation Directory>`

## Installation of JOnAS

Download the binary version of JOnAS from the ObjectWeb web site.
Choose a location for the JOnAS installation.
Beware that if you have already installed a previous version of JOnAS in this location the new installation will overload previous files and you may loose configuration files that you may have customized. So it is prudent to save these files before starting the installation process.
The installation process consists on unzipping the downloaded file.
To unzip this file, just go where you want to install JOnAS, and unzip it.
You can use `gunzip jonas2.tgz` and `tar -xvf jonas2.tar`.
After having installed the JOnAS product, all you have to do is to set this variable in your environment :

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

From the version 2.6.1 of JOnAS, you need to do a `ant install` in the `JONAS_ROOT` directory.
Note : This step has to be executed every time you want to use a new version of Tomcat or change the ORB.

## Setup

There are just a few setup points to do before you can use JOnAS :

- Depending on the ORB you are going to work with, change the `$JONAS_ROOT/config/jndi.properties` file (this file is already set if you want to use RMI with the default port). You also have to initialize the following environment variable to the correct value :
  `export OBJECTWEB_ORB = RMI / JEREMIE / DAVID`
- Depending on the data source you want to use, you have to create a file `<data source>.properties` (you can find some templates in the directory `$JONAS_ROOT/config`). Then add the data source file name (without the extension `.properties`) in the `jonas.properties` file :
  `jonas.service.dbm.datasource <data source>`
  In the file `$JONAS_ROOT/bin/unix/config_env`, set the path to the JDBC driver of the database used.
  For example, for PostgreSQL :
  `CLASSPATH=/usr/lib/pgsql/jdbc7.0-1.2.jar:$CLASSPATH`
- If you want to use jadmin, you need to add the following line to the file `$CATALINA_HOME/conf/tomcat-users.xml` :
  `<user name="jadmin" password="jonas" roles="jadmin, tomcat" />`
- For the example Petstore, you need to add the following line to the file `$CATALINA_HOME/conf/tomcat-users.xml` :
  `<user name="jps_admin" password="admin" roles="administrator" />`
- To use the security (examples websample and earsample), you need to replace the following line to the file `$CATALINA_HOME/conf/server.xml` :
  `<Realm className="org.apache.catalina.realm.MemoryRealm"/>`
  By the line :
  `<Realm className="org.objectweb.security.tomcat.interceptor.SecurityCtxInterceptor41" />`
- Configure the Mail service if you want to use it (for PetStore or the example mailsb for instance). JOnAS provides two types of mail factories : `javax.mail.Session` and `javax.mail.internet.MimePartDataSource`. In the directory `$JONAS_ROOT/config`, you can find two files : `MailSession1.properties` and `MailMimePartDS1.properties` that you can adapt to fit your installation. Then, in the `jonas.properties` file, define the `jonas.service.mail.factories` property :
  `jonas.service.mail.factories MailSession1,MailMimePartDS1`

You can then compile the examples :
`ant install` in the directory `$JONAS_ROOT/examples`

You are now ready to use JOnAS. For more information, consult the JOnAS Documentation