Spring WS - Environment Setup



In this Chapter, we will understand the process of setting up Spring-WS on Windows and Linux based systems. The Spring-WS can be easily installed and integrated with your current Java environment and MAVEN by following a few simple steps without any complex setup procedures. User administration is required while installation.

System Requirements

The following table lists out the system requirements, while the subsequent steps will guide us through the environment setup procedure.

JDK Java SE 2 JDK 1.5 or above
Memory 1 GB RAM (recommended)
Disk Space No minimum requirement
Operating System Version Windows XP or above, Linux

Let us now proceed with the steps to install Spring-WS.

Step 1: Verify the Java Installation

To begin with, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the following two commands depending on the platform you are working on.

If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

Platform Command Sample Output
Windows

Open command console and type −

\>java -version

Java version "1.7.0_60"

Java (TM) SE Run Time Environment (build 1.7.0_60-b19)

Java Hotspot (TM) 64-bit Server VM (build 24.60-b09,mixed mode)

Linux

Open command terminal and type −

$java -version

java version "1.7.0_25"

Open JDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64)

Open JDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Step 2: Set your Java Environment

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

S.No. Platform & Description
1

Windows

Set JAVA_HOME to C:\ProgramFiles\java\jdk1.7.0_60

2

Linux

Export JAVA_HOME=/usr/local/java-current

Append the full path of Java compiler location to the System Path.

S.No. Platform & Description
1

Windows

Append the String "C:\Program Files\Java\jdk1.7.0_60\bin" to the end of the system variable PATH.

2

Linux

Export PATH=$PATH:$JAVA_HOME/bin/

Execute the command java -version from the command prompt as explained above.

Step 3: Download Maven archive

Download Maven 3.3.3 from https://maven.apache.org/download.cgi

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

Step 4: Extract the Maven archive

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

OS Location (can be different based on your installation)
Windows C:\Program Files\Apache Software Foundation\apache-maven-3.3.3
Linux /usr/local/apache-maven
Mac /usr/local/apache-maven

Step 5: Set Maven environment variables

Add M2_HOME, M2 and MAVEN_OPTS to the environment variables.

OS Output
Windows

Set the environment variables using system properties.

M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.3.3

M2=%M2_HOME%\bin

MAVEN_OPTS=-Xms256m -Xmx512m

Linux

Open command terminal and set environment variables.

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

export M2=$M2_HOME/bin

export MAVEN_OPTS=-Xms256m -Xmx512m

Mac

Open command terminal and set environment variables.

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

export M2=$M2_HOME/bin

export MAVEN_OPTS=-Xms256m -Xmx512m

Step 6: Add Maven bin directory location to the system path

Now append M2 variable to the 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 7: Verify Maven installation

Now open the 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 something as shown below −

OS Output
Windows

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)

Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.3.3

Java version: 1.7.0_75, vendor: Oracle Corporation

Java home: C:\Program Files\Java\jdk1.7.0_75\jre

Default locale: en_US, platform encoding: Cp1252

Linux

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)

Maven home: /usr/local/apache-maven/apache-maven-3.3.3

Java version: 1.7.0_75, vendor: Oracle Corporation

Java home: /usr/local/java-current/jdk1.7.0_75/jre

Mac

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)

Maven home: /usr/local/apache-maven/apache-maven-3.3.3

Java version: 1.7.0_75, vendor: Oracle Corporation

Java home: /Library/Java/Home/jdk1.7.0_75/jre

Step 8: Setup Eclipse IDE

All the examples in this tutorial have been written using the Eclipse IDE. It is recommended that the readers should have the latest version of Eclipse installed on their machine. To install the Eclipse IDE, download the latest Eclipse binaries from the following link https://www.eclipse.org/downloads/. Once the installation is downloaded, unpack the binary distribution into a convenient location.

For example in C:\eclipse on windows, or /usr/local/eclipse on Linux/Unix and finally set the PATH variable appropriately. Eclipse can be started by executing the following commands on the windows machine, or you can simply double click on eclipse.exe.

%C:\eclipse\eclipse.exe

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

$/usr/local/eclipse/eclipse

After a successful startup, if everything is fine then it should display the following screen −

Eclipse Home page

Step 9: Setup Apache Tomcat

We can download the latest version of Tomcat from https://tomcat.apache.org/. Once the installation is downloaded, unpack the binary distribution into a convenient location. For example in the C:\apache-tomcat-7.0.59 on a windows machine, or in the /usr/local/apache-tomcat-7.0.59 on a Linux/Unix machine and then set the CATALINA_HOME environment variable pointing to the installation locations.

Tomcat can be started by executing the following commands on a windows machine, or you can simply double click on startup.bat

%CATALINA_HOME%\bin\startup.bat
 
or
 
C:\apache-tomcat-7.0.59\bin\startup.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-7.0.59/bin/startup.sh

After a successful startup, the default web applications included with Tomcat will be available by visiting – http://localhost:8080/. If everything is ok, then it should display the following screen −

Tomcat

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

Tomcat can be stopped by executing the following commands on a windows machine −

%CATALINA_HOME%\bin\shutdown

or

C:\apache-tomcat-7.0.59\bin\shutdown

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

$CATALINA_HOME/bin/shutdown.sh

or

/usr/local/apache-tomcat-7.0.59/bin/shutdown.sh

Once we are done with this last step, we are ready to proceed for the first Web Services Example, which we will discuss in the next chapter.

Advertisements