Use the Eclipse plug-in to deploy applications

Alibaba Cloud Toolkit for Eclipse (Cloud Toolkit) is a free plug-in used for integrated
development environment (IDE). After you develop, debug, and test an application on
the premises, you can use this plug-in to deploy the application to an ECS instance.
This topic describes how to use the Eclipse plug-in to deploy a Java application on
an ECS instance.

Step 1: Install Cloud Toolkit

Enter a name such as Cloud Toolkit for Eclipse and the software location http://toolkit.aliyun.com/eclipse, and click Add.

In the Name column, select Alibaba Cloud Toolkit Core and Alibaba Cloud Toolkit Deployment Tools, and clear Contact all update sites during install to find required software in the Details section, and then 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

The AccessKey ID and AccessKey Secret are issued to users by Alibaba Cloud. 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 pair must be kept confidential.

Enter the AccessKey ID and AccessKey Secret, and click Apply and Close.

Note

If you have an account but have not generated any AccessKey pair, click Get existing AK/SK, and log on to the Alibaba Cloud console to generate an AccessKey pair. For more
information, see Create an AccessKey pair.

If you have not created any account, click Sign up.

Step 3: Download and upload the JDK installation package

To download and upload the JDK installation package, follow these steps:

Note If you download the JDK package on an ECS instance, an error occurs during decompression.
You can download the JDK installation package to your local directory and upload the
package to the ECS instance.

If SELinux stays in the Enforcing state, SELinux is enabled. In this example, SELinux is in the Enforcing state, so
you must disable SELinux.

Disable SELinux. Skip this step if SELinux is in the Disabled state.

To temporarily disable SELinux, run the command setenforce 0.

Note Therefore, SELinux is temporarily disabled, and will remain in the Enforcing state
when you restart Linux next time.

To permanently disable SELinux, follow these steps: Run the command vi /etc/selinux/config, and press the Enter key. Move the pointer to the line of SELINUX=enforcing, and press the i key to enter the edit mode. Edit the SELinux state in this way: SELINUX=disabled. Afterward, press the Esc key, type :wq, and then press the Enter key to save and close the SELinux configuration file.

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,
you connect to http://Public IP address of the ECS instance:8080 to view Tomcat test. Follow these steps:

In Eclipse, right-click the name of the application project that you want to deploy,
and choose Alibaba Cloud > Deploy to ECS....

In the window Deploy to Alibaba Cloud that appears, follow these settings:

Deploy File: the deployment method, such as Upload File in this example. If you build the application project by using Maven, select Maven Build.

Choose File: the file that you want to deploy.

Target Deploy ECS: specifies the region where your instance is located and the target instance.

Deploy Location: the directory that you deploy on the ECS instance, such as /data/wwwroot/default in this example.

Command: Click Select..., and in the dialog box that appears, click Add.... Enter a command in the text box. The ECS instance runs the command automatically
after the Cloud Toolkit plug-in 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 another command as needed.

Click Deploy to start deploying the Java application to the ECS instance.

In the Console section of Eclipse, you can view the progress of the deployment.

Open your browser, and in the address bar, enter the URL http://Public IP address of the ECS instance:8080 to connect to the ECS instance.

The following response indicates that the Java application has been 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 then use the Cloud
Toolkit plug-in again to deploy the modified file to the ECS instance.