JBoss AS 5 Development
上QQ阅读APP看书,第一时间看更新

Installing the Java environment

JBoss is a pure Java application server, so as you might imagine it needs a virtual machine for the Java Platform to run on.

At the time of writing, JBoss AS 5 is distributed in two flavors, one that is suited for Java 1.5 and another version that has been specifically designed for Java 1.6.

The choice of Java Virtual Machine (JVM) is yours otherwise, but we do recommend considering the Java 1.6, that has just undergone the 16th update at the time of writing. Most benchmarks available on the Internet exhibit a roughly 40 percent performance improvement by upgrading from Java 1.5 to Java 1.6. Additionally, Java SE 5.0 reached its End of Service Life (EOSL) on November 3, 2009, which is the date of the final publicly available update of version 5.0. So you are highly encouraged to design your applications with Java 1.6.

Note

Java 1.6 has enhanced performance in many areas of the platform. Improvements include synchronization, performance optimizations, compiler performance optimizations, the new Parallel Compaction Collector, better ergonomics for the Concurrent Low Pause Collector, and application startup performance.

(http://java.sun.com/performance/reference/whitepapers/6_performance.html)

So let's move on to the Sun download page: http://java.sun.com/javase/downloads/index.jsp.

Choose to download the latest JDK/JRE, which is for JDK 1.6 Update 16.

Installing the Java environment

Tip

Is JRE enough ?

Yes! JBoss 5 ships with a set of libraries called Eclipse Java development tools (JDT) that allow dynamic compilation of classes at runtime. However, we still suggest you to download the full JDK installation, in case you need to compile your classes with plain javac anywhere else.

Once the download is complete, run the executable file to start the installation.

jdk-6-windows-i586.exe # Windows
sh jdk-6u12-linux-i586.bin # Linux

If you are installing on a Linux/Unix box, you can safely accept all the defaults given to you by the setup wizard. Windows users should stay away from the default C:\Program Files that leads to some issues when you are referencing the core libraries. An installation path such as C:\Software\Java or simply C:\Java is a better alternative.

When the installation is complete, we need to update a couple of settings on the computer so that it can interact with Java.

The most important setting is JAVA_HOME that is directly referenced by JBoss startup script.

Windows XP/2000 users should right-click on My Computer and select Properties from the context menu. On the Advanced tab, click the Environment Variables button. Then, in the System variables box click New. Give the new variable a name of JAVA_HOME, and a value of the path to your JDK installation, probably something like C:\Java\jdk1.6.0_16.

Installing the Java environment

Tip

For Windows Vista users

Because of increased security in Windows Vista, standard users must have User Account Control (UAC) turned on to change environment variables and the change must be completed through User Accounts. In the User Accounts window, under Tasks, select Change my environment variables. Use the New, Edit, or Delete buttons to add, change, or delete environment variables.

Now it's the turn of the Path variable. Double-click on the Path system variable. In the box that pops up, navigate to the end of the Variable value line, add a semicolon to the end, then add the path to your JDK. This will be something like %JAVA_HOME% \bin.

Unix/Linux users can add the following commands in the user's profile scripts:

export JAVA_HOME=/installDir/jdk1.6.0_16
export PATH=$JAVA_HOME/bin:$PATH

As a final note, you should consider setting the JBOSS_HOME environment variable, which points to the root of the application server. (In our case, it would be C:\jboss-5.0.0.GA for Windows users.)

If you don't set this variable, the startup script simply guesses the location of JBoss AS by climbing one step up from the bin folder.