Alibaba Cloud Toolkit for Eclipse (Cloud Toolkit) is a free plug-in used for an integrated
development environment (IDE). After you develop, debug, and test an application on
your computer, you can use this plug-in to deploy the application to an Elastic Compute
Service (ECS) instance.
Background information
This topic describes how to install Cloud Toolkit in Eclipse on your Windows computer
and then use Cloud Toolkit to deploy a Java application to an ECS instance.
Step 1: Install Cloud Toolkit on your Windows computer
- Start Eclipse on your Windows computer.
- In the top navigation bar of the Eclipse window, choose
- Click Add...
- Enter a name such as Cloud Toolkit for Eclipse in the Name field, enter http://toolkit.aliyun.com/eclipse in the Location field, and then click Add.
- In the Name column, select Alibaba Cloud Toolkit Core and Alibaba Cloud Toolkit Deployment Tools. In the Details section, clear Contact all update sites during install to find required software. Then, click Next.
- Click Next.
- Select I accept the terms of the license agreement and click Finish.
You can view the installation progress of Cloud Toolkit in the lower-right corner
of the Eclipse window.
- While Cloud Toolkit is being installed, the Security Warning dialog box appears. In the Security Warning dialog box, click Install anyway.
- After Cloud Toolkit is installed, the Software Updates dialog box appears. In the Software Updates dialog box, click Restart Now to restart Eclipse.
After specific versions of Eclipse are restarted, they must be activated for use by
using an activation code. You must obtain an activation code and activate Eclipse
on your own.
Step 2: Configure an AccessKey pair
An AccessKey ID identifies a user. An AccessKey secret encrypts the signature string
and is the key that the server uses to authenticate the signature string. The AccessKey
pair must be kept confidential.
Perform the following operations to configure the AccessKey ID and AccessKey secret.
- In the top navigation bar of the Eclipse window, choose .
- In the left-side navigation pane, choose .
- Specify AccessKey ID and AccessKey Secret, and click Apply and Close.
Step 3: Download and upload a JDK installation package
- Download Apache Tomcat. For more information, visit Index of /apache/tomcat/tomcat-8/.
Note The source code is constantly upgraded and you can obtain the version that is appropriate
to your needs.
- Download a JDK installation package. For more information, visit Java Downloads.
Note If you download a JDK installation package for Linux to the instance, an error occurs
when you decompress the package. To avoid this error, you can download a JDK installation
package for Linux to your computer and then upload the package to the instance.
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- On the Instances page, find the Linux instance and view its public IP address in the
IP Address column.
- In WinSCP, use the public IP address to connect to the Linux instance. Then, upload
the JDK installation package to the root directory of the instance.
Step 4: Make preparations
- Log on to the Linux instance.
- Disable the firewall.
- Run the systemctl status firewalld command to check the state of the firewall.
- If the firewall is disabled, it is in the inactive state.
- If the firewall is enabled, it is in the active state. In this example, the firewall is in the active state and must be disabled.
- Disable the firewall. Skip this step if the firewall is already disabled.
- To temporarily disable the firewall, run the following command:
systemctl stop firewalld
Note After you run the preceding command, the firewall is disabled. The next time you restart
the Linux operating system, the firewall is re-enabled and enters the active state.
- To permanently disable the firewall, run the following commands in turn.
- To disable the running firewall, run the following command:
systemctl stop firewalld
- To stop the firewall service and configure the service not to automatically start
on instance startup, run the following command:
systemctl disable firewalld
Note After you run the preceding commands, the firewall is disabled. The next time you
restart the instance, the firewall remains disabled by default. You can re-enable
the firewall. For more information, see
Firewalld documentation.
- Disable SELinux.
- Check the state of SELinux.
Example command output:

- If SELinux is disabled, it is in the Disabled state.
- If SELinux is enabled, it is in the Enforcing state. In this example, SELinux is in the Enforcing state and must be disabled.
- Disable SELinux. Skip this step if SELinux is already disabled.
- To temporarily disable SELinux, run the following command:
setenforce 0
Note After you run this command, SELinux is disabled. The next time you restart the Linux
operating system, SELinux is re-enabled and enters the Enforcing state.
- To permanently disable SELinux, run the following command to open the SELinux configuration
file:
vi /etc/selinux/config
In the /etc/selinux/config file, move the pointer on the SELINUX=enforcing
line and press the I key to enter the edit mode. Set SELINUX
to disabled. Press the Esc key, enter :wq
, and then press the Enter key to save and close the SELinux configuration file.
- Restart the system for the changes to take effect.
- Create a user named www to run Tomcat.
- Create a website root directory.
mkdir -p /data/wwwroot/default
- Change the owner of the website root directory to www.
chown -R www.www /data/wwwroot
Step 5: Install JDK
- Create a directory.
- Decompress the JDK installation package.
In this example, the
jdk-8u241-linux-x64.tar.gz JDK installation package is decompressed to the
/usr/java directory.
chmod +x jdk-8u241-linux-x64.tar.gz
tar xzf jdk-8u241-linux-x64.tar.gz -C /usr/java
- Set environment variables.
- Open the /etc/profile file.
- Press the
I
key to enter the edit mode.
- Add the following lines to the /etc/profile file:
# set java environment
export JAVA_HOME=/usr/java/jdk1.8.0_241
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
- Press
Esc
to exit the edit mode. Enter :wq
and press the Enter key to save and close the file.
- Load environment variables.
- View JDK version information.
If JDK is installed, JDK version information is displayed.

Step 6: Install Apache Tomcat
- In the system root directory, run the following commands in turn.
- Decompress apache-tomcat-8.5.53.tar.gz.
tar xzf apache-tomcat-8.5.53.tar.gz
- Move and rename the Tomcat directory.
mv apache-tomcat-8.5.53 /usr/local/tomcat/
- Configure user permissions on the Tomcat directory.
chown -R www.www /usr/local/tomcat/
The
/usr/local/tomcat/ directory contains the following subdirectories:
- bin: stores some Tomcat script files, such as those used to enable and disable the Tomcat
service.
- conf: stores various global configuration files of the Tomcat server, among which server.xml and web.xml are the most important files.
- webapps: serves as the main web publishing directory of Tomcat. It stores web application
files by default.
- logs: stores Tomcat operation log files.
- Configure the server.xml file.
- Switch to the /usr/local/tomcat/conf/ directory.
cd /usr/local/tomcat/conf/
- Rename the server.xml file.
mv server.xml server.xml_bk
- Open the server.xml file.
- Press the I key to enter the edit mode.
- Add the following content to the file:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8006" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxThreads="1000"
minSpareThreads="20"
acceptCount="1000"
maxHttpHeaderSize="65536"
debug="0"
disableUploadTimeout="true"
useBodyEncodingForURI="true"
enableLookups="false"
URIEncoding="UTF-8"/>
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="/data/wwwroot/default" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/data/wwwroot/default" debug="0" reloadable="false" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
- Press the Esc key to exit the edit mode. Enter
:wq
and press the Enter key to save and close the file.
- Set Java Virtual Machine (JVM) memory parameters.
- Create and open the /usr/local/tomcat/bin/setenv.sh file.
vi /usr/local/tomcat/bin/setenv.sh
- Press the I key to enter the edit mode.
- Add the following content to the file:
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
- Press the Esc key to exit the edit mode. Enter
:wq
and press the Enter key to save and close the file.
- Configure a script to run Tomcat on system startup.
- Download the script.
Note This script originates from the community and is for reference only. Alibaba Cloud
does not make any guarantee, express or implied, with respect to the performance and
reliability of the script or the potential impacts of the script operations.
wget http://raw.githubusercontent.com/oneinstack/oneinstack/master/init.d/Tomcat-init
- Rename Tomcat-init.
mv Tomcat-init /etc/init.d/tomcat
- Grant the execute permissions on the /etc/init.d/tomcat file.
chmod +x /etc/init.d/tomcat
- Configure the JAVA_HOME script to run Tomcat on system startup.
Notice The JDK version in the script must be the same as that you installed. Otherwise, Tomcat
cannot start.
sed -i 's@^export JAVA_HOME=.*@export JAVA_HOME=/usr/java/jdk1.8.0_241@' /etc/init.d/tomcat
- Configure Tomcat to automatically run on system startup.
chkconfig --add tomcat
chkconfig tomcat on
- Start Tomcat.
Step 7: Deploy a Java application to an ECS instance
You can use Cloud Toolkit to deploy a Java application to the ECS instance. Then,
Tomcat test
is displayed when you access http://<Public IP address of the ECS instance>:8080.
- In Eclipse, right-click the name of the application project that you want to deploy
and choose
- In the Deploy to Alibaba Cloud dialog box, complete the following settings:
- Deploy File: Specify a deployment method. In this example, Upload File is selected. If you built the application project by using Maven, select Maven Build.
- Choose File: Select the file that you want to deploy.
- Target Deploy ECS: Select a region and an ECS instance.
- Deploy Location: Enter a directory that you deployed on the ECS instance. In this example, /data/wwwroot/default is used.
- Command: Click Select... In the dialog box that appears, and then click Add.... Enter a command in the text box. This command is automatically executed after Cloud
Toolkit deploys the Java application to the specified directory on the ECS instance.
In this example, service tomcat restart is entered to restart Tomcat. You can also enter another command based on your business
needs.

- Click Deploy to start deploying the Java application to the ECS instance.
- In the Console section of Eclipse, you can view the deployment progress.
- Open your browser and enter
http://<Public IP address of the ECS instance>:8080
in the address bar to connect to the ECS instance.
If the Java application is deployed to the ECS instance by using Cloud Toolkit, the
information shown in the following figure is displayed.

What to do next
You can modify the Java application in Eclipse, save the code, and then use Cloud
Toolkit again to deploy the modified file to the ECS instance.