Alibaba Cloud Toolkit for Eclipse (Cloud Toolkit) is a free plug-in used for the integrated
development environment (IDE). After you develop, debug, and test an application on
a local server, you can use this plug-in to deploy the application to an ECS instance.
Background information
This topic describes how to install Cloud Toolkit in Eclipse in your local server
that uses the Windows operating system and use Cloud Toolkit to deploy a Java application
to an instance.
Step 1: Install Cloud Toolkit
To install Cloud Toolkit in Windows, follow these steps:
- Start Eclipse.
- On the toolbar, choose .
- Click Add... in the dialog box that appears.
- Enter a name such as Cloud Toolkit for Eclipse, enter the http://toolkit.aliyun.com/eclipse software location, and click Add.
- In the Name column, select Alibaba Cloud Toolkit Core and Alibaba Cloud Toolkit Deployment Tools, clear Contact all update sites during install to find required software in the Details section, and click Next.
- Click Next.
- Select I accept the terms of the license agreement and click Finish.
- Click Install anyway.
- Click Restart Now to restart Eclipse.
Step 2: Set the AccessKey pair
An AccessKey ID is used to identify a user. An AccessKey secret is used to encrypt
the signature string and is the key that the server uses to authenticate the signature
string. The AccessKey secret must be kept confidential.
To set the AccessKey ID and AccessKey secret, follow these steps:
- On the toolbar, choose .
- In the left-side navigation pane, choose .
- Set Access Key ID and Access Key secret, and click Apply and Close.
Step 3: Download and upload the JDK installation package
To download and upload the JDK installation package, follow these steps:
- Download Apache Tomcat.
Note The source code is constantly upgraded and you can obtain the appropriate version
as needed.
- Download the JDK installation package.
Note If you download a JDK installation package to a Linux instance, an error will occur
when you decompress the package. You can download a JDK installation package for Linux
to your computer and then upload it to the instance.
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Find the target instance on the Instances page, and obtain the public IP address of
the instance from the IP Address column.
- Start WinSCP, use the public IP address to connect to the Linux instance, and upload
the JDK installation package to the root directory of the Linux instance.
Step 4: Prepare for installation
To prepare for installation, follow these steps:
- Establish a remote connection to the ECS instance. For more information, see Connect to a Linux instance from the console.
- Disable the firewall.
- Run the systemctl status firewalld command to check the status of the firewall.
- If the firewall is in the inactive state, the firewall is disabled.
- If the firewall is in the active state, the firewall is enabled. In this example, the firewall is in the active state,
so you need to disable the firewall.
- Disable the firewall. Skip this step if the firewall is in the inactive state.
- To temporarily disable the firewall, run the systemctl stop firewalld command.
Note The firewall is temporarily disabled, and will enter the active state when you restart
the Linux operating system next time.
- To permanently disable the firewall, run the systemctl disable firewalld command.
Note You can enable the firewall again. For more information, visit the
firewalld.
- Disable SELinux.
- Run the getenforce command to check the status of SELinux.
- If SELinux is in the Disabled state, SELinux is disabled.
- If SELinux is in the Enforcing state, SELinux is enabled. In this example, SELinux is in the Enforcing state, so
you need to disable SELinux.
- Disable SELinux. Skip this step if SELinux is in the Disabled state.
- To temporarily disable SELinux, run the setenforce 0 command.
Note SELinux is temporarily disabled, and will enter the Enforcing state when you restart
the Linux operating system next time.
- To permanently disable SELinux, run the vi /etc/selinux/config command and press the Enter key. Move the pointer over the line of
SELINUX=enforcing
, and press the I
key to enter the edit mode. Change the SELinux state to Disabled
. After that, press the Esc
key, enter :wq
, and 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 root directory for the Java web project.
mkdir -p /data/wwwroot/default
- Grant the file permission under the root directory of the website to www.
chown -R www.www /data/wwwroot
Step 5: Install JDK
To install JDK, follow these steps in the instance:
- Create a directory.
- Decompress the JDK installation package that is jdk-8u191-linux-x64.tar.gz in this example to /usr/java.
chmod +x jdk-8u191-linux-x64.tar.gz
tar xzf jdk-8u191-linux-x64.tar.gz -C /usr/java
- Configure environment variables.
- Run the vi /etc/profile command to open the /etc/profile file.
- Press the
I
key to enter the edit mode.
- Add the following lines into the /etc/profile file:
# set java environment
export JAVA_HOME=/usr/java/jdk1.8.0_191
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
- Press the
Esc
key to exit the edit mode and enter :wq
to save and close the file.
- Run the source /etc/profile command to load environment variables.
- Run the java -version command to check the JDK version.
If the JDK version information is returned as follows, JDK is installed.

Step 6: Install Apache Tomcat
To install Apache Tomcat, follow these steps in the instance:
- Run the following commands in sequence to decompress the apache-tomcat-8.5.34.tar.gz package, rename the Tomcat directory, and configure user permissions:
tar xzf apache-tomcat-8.5.34.tar.gz
mv apache-tomcat-8.5.34 /usr/local/tomcat/
chown -R www.www /usr/local/tomcat/
The
/usr/local/tomcat/ directory contains the following files:
- bin: stores some Tomcat script files, including scripts used to enable and disable the
Tomcat service.
- conf: stores global configuration files for the Tomcat server, including the important
files server.xml and web.xml.
- webapps: the main web publishing directory of Tomcat and stores web application files by
default.
- logs: stores Tomcat log files.
- Configure the server.xml file.
- Run the cd /usr/local/tomcat/conf/ command to switch to the /usr/local/tomcat/conf/ directory.
- Run the mv server.xml server.xml_bk command to rename the server.xml file.
- Run the vi server.xml command to open the file.
- Press the
I
key to enter the edit mode.
- Add the following code:
<? 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.
- Run the vi /usr/local/tomcat/bin/setenv.sh command to create a file named /usr/local/tomcat/bin/setenv.sh.
- Press the
I
key to enter the edit mode.
- Add the following code:
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 Enter to save and close the file.
- Configure a script to run Tomcat at system startup.
- Run the wget https://github.com/lj2007331/oneinstack/raw/master/init.d/Tomcat-init command to download the script.
- Run the mv Tomcat-init /etc/init.d/tomcat command to rename the downloaded Tomcat-init file.
- Run the chmod +x /etc/init.d/tomcat command to assign the executable permission to the script file.
- Run the following command to set the
JAVA_HOME
startup script:
Notice The JDK version information in the script must be the same as that of the JDK version
you installed. Otherwise, Tomcat will fail to start.
sed -i 's@^export JAVA_HOME=.*@export JAVA_HOME=/usr/java/jdk1.8.0_191@' /etc/init.d/tomcat
- Configure Tomcat to automatically start at system startup.
chkconfig --add tomcat
chkconfig tomcat on
- Start Tomcat.
Step 7: Deploy a Java application to the ECS instance
You can use Cloud Toolkit to deploy a Java application to the ECS instance. Then,
Tomcat test
is displayed when you visit http://Public IP address of the ECS instance:8080. Follow these steps:
- In Eclipse, right-click the name of the application project that you want to deploy,
and choose from the shortcut menu.
- In the Deploy to Alibaba Cloud dialog box that appears, complete the following settings:
- Deploy File: Select a deployment method. Select Upload File in this example. If you build the application project by using Maven, select Maven Build.
- Choose File: Select the file that you want to deploy.
- Target Deploy ECS: Specify the region where your instance is located and select an instance.
- Deploy Location: Enter the directory that you deployed on the ECS instance, such as /data/wwwroot/default in this example.
- Command: Click Select... and click Add... in the dialog box that appears. Enter a command in the field. The ECS instance runs
the command automatically after Cloud Toolkit deploys the Java application to the
directory on the ECS instance. In this example, enter the service tomcat restart command to restart Tomcat. You can also enter other commands as needed.

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

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