Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Struts2 environment settings


May 15, 2021 Struts2


Table of contents


Our first task was to run a minimal Struts2 application. T his chapter will show you how to build a Struts2 development environment. Let's say your PC already has JDK (5 plus), Tomcat, and Eclipse installed, and if you don't have these components installed, follow the shortcuts listed below:

Step 1 - Install the Java Development Kit (JDK):

You can download the latest version of SDK: Java SE download link on the Java page of Oracle's website. I n the download file you can see the instructions for installing the JDK and follow the instructions for installing and configuring the settings. Finally, set the path and JAVA_HOME environment variables to the referenced directory that contains Java and Java, typically java_install_dir/bin and java_install_dir.

If you're installing the SDK to C: jdk1.5.0_20 windows system, you'll need to put the following code in your C: .bat C: .

set PATH=C:\jdk1.5.0_20in;%PATH%
set JAVA_HOME=C:\jdk1.5.0_20
In addition, in Windows NT/2000/XP, you can right-click On My Computer, select Properties → Advanced → Environment Variables, and then update the path value and press the OK button.

In Unix (or Solaris, Linux, etc.), if the SDK is installed on disk C /usr/local/jdk1.5.0_20, you can put the following code into the .cshrc file.

setenv PATH /usr/local/jdk1.5.0_20/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.5.0_20

Also, if you're using an integrated development environment (IDE) like Borland JBuilder, Eclipse, IntelliJ IDEA, or Sun ONE Studio, compile and run a simple program to confirm that the IDE has found the location of the Java you installed, otherwise you'll set it up correctly according to the documentation given by the IDE.

Step 2 - Install Apache Tomcat:

You can download the latest version of Tomcat from this address: http://tomcat.apache.org/. Once you've downloaded the installer, unzip the binary release package to a convenient location, such as Windows's C:?apache-tomcat-6.0.33, Linux or Unix's /usr/local/apache-tomcat-6.0.33, and create CATALINA_HOME environment variables to point to those locations.
In a Windows environment, You can start Tomcat by following the instructions below, or you can just double-click startup .bat.
%CATALINA_HOME%in\startup.bat 
 or 
 C:\apache-tomcat-6.0.33in\startup.bat
In a Unix (or Solaris, Linux, etc.) environment, Tomcat can be started by executing the following instructions:
$CATALINA_HOME/bin/startup.sh
or 
/usr/local/apache-tomcat-6.0.33/bin/startup.sh
After successful startup, the default web program that contains Tomcat can be accessed http://localhost:8080/ the user. If all goes well, the following results are displayed:

Struts2 environment settings

More documentation on configuring and running Tomcat can be found here, as well as on the Tomcat website: http://tomcat.apache.org.
In a Windows environment, You can stop Tomcat by following the following instructions:
%CATALINA_HOME%in\shutdown
or
C:\apache-tomcat-5.5.29in\shutdown
In a Unix (or Solaris, Linux, etc.) environment, Tomcat can be stopped by executing the following instructions:
$CATALINA_HOME/bin/shutdown.sh
or
/usr/local/apache-tomcat-5.5.29/bin/shutdown.sh

Step 3 - Install Eclipse (IDE)

All the examples in this tutorial are using the Eclipse IDE, so we recommend that you install the latest version of Eclipse on your computer. Y ou can download and install the latest Eclipse: http://www.eclipse.org/downloads/. O nce you download the installer, unzip the binary release package to a convenient location, such as Windows's C:\eclipse, Linux or Unix's /usr/local/eclipse, and set the appropriate path variables.
In a Windows environment, you can start Eclipse by following instructions, or you can double-click eclipse .exe.
 %C:\eclipse\eclipse.exe
In a Unix (or Solaris, Linux, etc.) environment, Eclipse can be started by executing the following instructions:
$/usr/local/eclipse/eclipse
If all goes well after a successful startup, the following results are displayed:

Struts2 environment settings

Step 4 - Install the Struts2 vault

If all goes well, now that you can continue to install your Struts2 framework, here are the easy steps to download and install Struts2 on your computer:
  • Choose whether you want to install Struts2 on Windows or Unix, and then proceed to the next step to download the compressed files for Windows or Unix.
  • Download the latest version of the Struts2 binary at this address: http://struts.apache.org/download.cgi.
  • When we wrote this tutorial, we downloaded struts-2.0.14-all.zip, which shows the following directory structure in C: struts-2.2.3 when you unziw the downloaded file:
Struts2 environment settings

Next is to unzip the zip file anywhere, and we download and unzip the struts-2.2.3-all.zip in the C:-folder of windows 7 computers, so that we can put all the jar files in C: struts-2.2.3-lib. Make sure you set the CLASSPATH variable correctly, or you'll run into problems running your application.