Amazon Elastic Compute Cloud
User Guide (API Version 2011-12-15)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Prerequisites

This document assumes that the reader is comfortable working in a Linux/UNIX or Windows environment.

An installation of a Java 5 compatible Java Runtime Environment (JRE) is required. Additionally, accessing Linux and UNIX instances requires access to an SSH client and accessing Windows instances requires access to a Remote Desktop client. For more information, refer to the two following sections.

As a convention, all command line text is prefixed with a generic PROMPT> command line prompt. The actual command line prompt on your machine is likely to be different. We also use $ to indicate a Linux/UNIX specific command and C:\> for a Windows specific command. Although we don't provide explicit instructions, the tools also work correctly on Mac OS X (which resemble the Linux and UNIX commands). The example output resulting from the command is shown immediately thereafter without any prefix.

Setting the Java Home Variable

The Amazon EC2 command line tools require Java version 5 or later to run. Either a JRE or JDK installation is acceptable. To view and download JREs for a range of platforms, including Linux/UNIX and Windows, go to http://java.sun.com/j2se/1.5.0/.

The command line tools depend on an environment variable (JAVA_HOME) to locate the Java runtime. This environment variable should be set to the full path of the directory that contains a subdirectory named bin which in turn contains the java (on Linux and UNIX) or the java.exe (on Windows) executable. You might want to simplify things by adding this directory to your path before other versions of Java. Make sure you don't include the bin directory in the path; that's a common mistake some users make. The command line tools won't work if you do.

[Note]Note

If you are using Cygwin, EC2_HOME, EC2_PRIVATE_KEY, and EC2_CERT, you must use Linux/UNIX paths (e.g,, /usr/bin instead of C:\usr\bin). However, JAVA_HOME should have a Windows path. Additionally, the value of EC2_HOME cannot contain any spaces, even if the value is quoted or the spaces are escaped.

On Linux and UNIX, you can set this environment variable as follows.

$ export JAVA_HOME=<PATH>
[Note]Note

The export command applies only to the current shell session. To permanently create or update an environment variable, include the command in a start-up script. For example, if you use Bash shell, you can include commands in your ~/.bashrc or /etc/profile file.

An example of the syntax in Windows follows (enclose the path in quotation marks if the path contains spaces).

C:\> set JAVA_HOME="<PATH>"
[Note]Note

The Windows environment variables are reset when you close the command window. You might want to set them permanently with the setx command.

You can confirm this by running $JAVA_HOME/bin/java -version and checking the output.

$ $JAVA_HOME/bin/java -version
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

The syntax is different on Windows, but the output is similar.

C:\> %JAVA_HOME%\bin\java -version
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

Accessing Linux and UNIX Instances through SSH Clients

For some of the examples illustrated here you'll need access to an SSH client. Most Linux and UNIX installations include an SSH client by default. If yours does not, the OpenSSH project provides a free implementation of the full suite of SSH tools. For more information, go to the http://www.openssh.org.

Windows users can download and install PuTTY, a free SSH client. To download the client and installation instructions, go to the http://www.chiark.greenend.org.uk/~sgtatham/putty/. For information on how to use PuTTY with Amazon EC2, see Connecting to Linux/UNIX Instances from Windows Using PuTTY.

Accessing Windows Instances through Remote Desktop Clients

Some of the examples in this guide require a Remote Desktop client. If you do not have one, go to the Microsoft home page.