Today I’m going to show you how to deploy simple java web application in amazon ec2 using Eclipse IDE.
Before we begin we need some required things,
- Eclipse Java EE IDE – You can download in http://www.eclipse.org/downloads/ (Im using Indigo version)
- Amazon Ec2 account – http://aws.amazon.com/ec2/ (Free account is enough)
- Some basic understanding about java web application
OK, lets start, here we go….
- First you have to install the AWS toolkit for eclipse plugin. Simply go to Help–> Eclipse Market Place –> Search Amazon
- You will get the AWS toolkit for eclipse .
- Click Install
- It will show the corresponding packages and after agree the license will install it. Just a simple procedure.
- Windows –> Preferences –> select AWS Toolkit and Fill the fields according to your amazon ec2 account
- Give your name to Account Name (Not Necessary), but give exact value to Access Key ID and Secret Access Key according to your amazon acc.
- In the optional configuration (Expand it) give account id (exact value) to that field.
- Windows –> Show view –> Other –> Select AWS toolkit view (Select all views) –> OK
- Now you can see the perspective view of aws.
- Now the configuration part is over.
- Lets create a Amazon ec2 server. To do that File –> New –> Other –> Server –> server –> select amazon ec2 or amazon elastic server tomcat version 6 (you can either choose tomcat version 7)
- Fill the fields and Finish. (Hope you have some basic understand about eclipse)
- Now create a Dynamic Web project. File –> New –> Other -> Web –> Dynamic Web Project
- Give whatever name you like.
- Choose AWS Ec2 or Elastic runtime as a target runtime.
- Click Finish
- Now create a servlet and Finish
- Change the doGet() in servlet (Only for demo. This is where your code goesssss)
- Right click Servlet –> Run as –> Run On server –> Select the server you above create and Finish.
- Eclipse will automatically open the web page that you created. (Or in server tab right click the server and select amazon web service –> running)
Just a simple procedure but you can expand this in your war… its up to you.
Reference: Complete Guide To Deploy Java Web Application in Amazon Ec2 using Eclipse from our JCG partner Rajith Delantha at the Looping around with Rajith… blog.