Book Image

JBoss AS 5 Development

Book Image

JBoss AS 5 Development

Overview of this book

JBoss AS is the most used Java application server on the market meeting high standards of reliability, efficiency, and robustness and is used to build powerful and secure Java EE applications. It supports the most important areas of Java Enterprise programming including EJB 3.0, dependency injection, web services, the security framework, and more. Getting started with JBoss application server development can be challenging; however, with the right approach and guidance, you can easily master it and this book promises that. Written in an easy-to-read style, this book will take you from the basics of JBoss ASósuch as installing core components and plug-insóto the skills that will make you a JBoss developer to be reckoned with, covering advanced topics such as developing applications with JBoss Messaging service, JBoss web services, clustered applications, and more. You will learn the necessary steps to install a suitable environment for developing enterprise applications on JBoss AS. Then, your journey will continue through the heart of the application server, explaining how to customize each service for optimal usage. You will learn how to design Enterprise applications using Eclipse and JBoss plug-ins. You will then learn how to enable distributed communication using JMS. Storing and retrieving objects will be made easier using Hibernate. The core section of the book will take you into the programming arena with tested, real-world examples. The example programs have been carefully crafted to be easy to understand and useful as starting points for your applications. This book will kick-start your productivity and help you to master JBoss AS development. The author's experience with JBoss enables him to share insights on JBoss AS development, in a clear and friendly way. By the end of the book, you will have the confidence to apply all the newest programming techniques to your JBoss applications.
Table of Contents (20 chapters)
JBoss AS 5 Development
Credits
About the Author
About the Reviewers
Preface
8
Developing Applications with JBoss and Hibernate
Index

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.

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.

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.