English 中文(简体)
JSF - Environment Setup
  • 时间:2024-11-03

JSF - Environment Setup


Previous Page Next Page  

This chapter will guide you on how to prepare a development environment to start your work with JSF Framework. You will learn how to setup JDK, Ecppse, Maven, and Tomcat on your machine before you set up JSF Framework.

System Requirement

JSF requires JDK 1.5 or higher so the very first requirement is to have JDK installed on your machine.

JDK 1.5 or above
Memory No minimum requirement
Disk Space No minimum requirement
Operating System No minimum requirement

Environment Setup for JSF Apppcation Development

Follow the given steps to setup your environment to start with JSF apppcation development.

Step 1: Verify Java installation on your machine

Open console and execute the following Java command.

OS Task Command
Windows Open Command Console c:> java -version
Linux Open Command Terminal $ java -version
Mac Open Terminal machine:~ joseph$ java -version

Let s verify the output for all the operating systems −

OS Generated Output
Windows

java version "1.6.0_21"

Java(TM) SE Runtime Environment (build 1.6.0_21-b07)

Java HotSpot(TM) Cpent VM (build 17.0-b17, mixed mode, sharing)

Linux

java version "1.6.0_21"

Java(TM) SE Runtime Environment (build 1.6.0_21-b07)

Java HotSpot(TM) Cpent VM (build 17.0-b17, mixed mode, sharing)

Mac

java version "1.6.0_21"

Java(TM) SE Runtime Environment (build 1.6.0_21-b07)

Java HotSpot(TM)64-Bit Server VM (build 17.0-b17, mixed mode, sharing)

Step 2: Set Up Java Development Kit (JDK)

If you do not have Java installed then you can install the Java Software Development Kit (SDK) from Oracle s Java site − Java SE Downloads. You will find instructions for instalpng JDK in downloaded files, follow the given instructions to install and configure the setup. Finally, set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.

Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine.

For example −

OS Output
Windows Set the environment variable JAVA_HOME to C:Program FilesJavajdk1.6.0_21
Linux Export JAVA_HOME=/usr/local/java-current
Mac Export JAVA_HOME=/Library/Java/Home

Append Java compiler location to System Path.

OS Output
Windows Append the string ;%JAVA_HOME%in to the end of the system variable, Path.
Linux Export PATH=$PATH:$JAVA_HOME/bin/
Mac Not required

Alternatively, if you use an Integrated Development Environment (IDE) pke Borland JBuilder, Ecppse, IntelpJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE knows where you installed Java. Otherwise, carry out a proper setup according to the given document of the IDE.

Step 3: Set Up Ecppse IDE

All the examples in this tutorial have been written using Ecppse IDE. Hence, we suggest you should have the latest version of Ecppse installed on your machine based on your operating system.

To install Ecppse IDE, download the latest Ecppse binaries with WTP support from https://www.ecppse.org/downloads/. Once you download the installation, unpack the binary distribution into a convenient location. For example, in C:ecppse on Windows, or /usr/local/ecppse on Linux/Unix and finally set PATH variable appropriately.

Ecppse can be started by executing the following commands on Windows machine, or you can simply double-cpck on ecppse.exe

%C:ecppseecppse.exe

Ecppse can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine −

$/usr/local/ecppse/ecppse

After a successful startup, if everything is fine then it will display the following result.

Ecppse Home page

*Note − Install m2ecppse plugin to ecppse using the following ecppse software update site

m2ecppse Plugin - https://m2ecppse.sonatype.org/update/.

This plugin enables the developers to run maven commands within ecppse with embedded/external maven installation.

Step 4: Download Maven archive

Download Maven 2.2.1 from https://maven.apache.org/download.html

OS Archive name
Windows apache-maven-2.0.11-bin.zip
Linux apache-maven-2.0.11-bin.tar.gz
Mac apache-maven-2.0.11-bin.tar.gz

Step 5: Extract the Maven archive

Extract the archive to the directory you wish to install Maven 2.2.1. The subdirectory apache-maven-2.2.1 will be created from the archive.

OS Location (can be different based on your installation)
Windows C:Program FilesApache Software Foundationapache-maven-2.2.1
Linux /usr/local/apache-maven
Mac /usr/local/apache-maven

Step 6: Set Maven environment variables

Add M2_HOME, M2, MAVEN_OPTS to environment variables.

OS Output
Windows

Set the environment variables using system properties.

M2_HOME=C:Program FilesApache Software Foundationapachemaven-2.2.1

M2=%M2_HOME%in

MAVEN_OPTS=-Xms256m -Xmx512m

Linux

Open command terminal and set environment variables.

export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1

export M2=%M2_HOME%in

export MAVEN_OPTS=-Xms256m -Xmx512m

Mac

Open command terminal and set environment variables.

export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1

export M2=%M2_HOME%in

export MAVEN_OPTS=-Xms256m -Xmx512m

Step 7: Add Maven bin directory location to system path

Now append M2 variable to System Path.

OS Output
Windows Append the string ;%M2% to the end of the system variable, Path.
Linux export PATH=$M2:$PATH
Mac export PATH=$M2:$PATH

Step 8: Verify Maven installation.

Open console, execute the following mvn command.

OS Task Command
Windows Open Command Console c:> mvn --version
Linux Open Command Terminal $ mvn --version
Mac Open Terminal machine:~ joseph$ mvn --version

Finally, verify the output of the above commands, which should be as shown in the following table.

OS Output
Windows

Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)

Java version: 1.6.0_21

Java home: C:Program FilesJavajdk1.6.0_21jre

Linux

Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)

Java version: 1.6.0_21

Java home: C:Program FilesJavajdk1.6.0_21jre

Mac

Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)

Java version: 1.6.0_21

Java home: C:Program FilesJavajdk1.6.0_21jre

Step 9: Set Up Apache Tomcat

You can download the latest version of Tomcat from https://tomcat.apache.org/. Once you download the installation, unpack the binary distribution into a convenient location. For example, in C:apache-tomcat-6.0.33 on Windows, or /usr/local/apache-tomcat-6.0.33 on Linux/Unix and set CATALINA_HOME environment variable pointing to the installation locations.

Tomcat can be started by executing the following commands on Windows machine, or you can simply double-cpck on startup.bat

%CATALINA_HOME%instartup.bat 
or 
C:apache-tomcat-6.0.33instartup.bat

Tomcat can be started by executing the following commands on Unix (Solaris, Linux, etc.) machine.

$CATALINA_HOME/bin/startup.sh 
or 
/usr/local/apache-tomcat-6.0.33/bin/startup.sh

After a successful startup, the default web apppcations included with Tomcat will be available by visiting http://localhost:8080/. If everything is fine, then it will display the following result.

Tomcat Home page

Further information about configuring and running Tomcat can be found in the documentation included here, as well as on the Tomcat web site − http://tomcat.apache.org

Tomcat can be stopped by executing the following commands on Windows machine.

%CATALINA_HOME%inshutdown 
or 
C:apache-tomcat-5.5.29inshutdown 

Tomcat can be stopped by executing the following commands on Unix (Solaris, Linux, etc.) machine.

$CATALINA_HOME/bin/shutdown.sh 
or 
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh
Advertisements