title: The image id '[ami-fd9cecc7]' does not exist
body: <p>I want to create EC2 Instance using this Java code remotely:</p>
  
  <pre><code>public void testEC2ServiceInRegion() throws Exception
      {
  
          String launchInstance = launchInstance();
          System.out.println("Status " + launchInstance);
      }
  
      public String launchInstance()
      {
          BasicAWSCredentials bawsc = new BasicAWSCredentials(
              "AKIAIUY1KF4KZV3DAL21", "Onv+nq33tUkiLl1Ib2H9JtIB732QMEesh01Jl73L");
  
          AmazonEC2 ec2 = new AmazonEC2Client(bawsc);
          System.out.println("\n\nLAUNCH INSTANCE\n\n");
  
          try
          {
              // Construct a RunInstancesRequest.
              RunInstancesRequest request = new RunInstancesRequest();
              request.setImageId("ami-fd9cecc7"); // the AMI ID, ami-fd9cecc7 is Amazon Linux AMI 2015.03 (HVM)
              request.setInstanceType("t2.micro");    // instance type
              request.setKeyName("desktop");      // the keypair
  //          request.setSubnetId("subnet-2dc0d459"); // the subnet
  //          ArrayList list = new ArrayList();
  //          list.add("sg-efcc248a");            // security group, call add() again to add more than one
  //          request.setSecurityGroupIds(list);
              request.setMinCount(1); // minimum number of instances to be launched
              request.setMaxCount(1); // maximum number of instances to be launched
  
              // Pass the RunInstancesRequest to EC2.
              RunInstancesResult  result  = ec2.runInstances(request);
              String instanceId = result.getReservation().getInstances().get(0).getInstanceId();
  
              // Return the first instance id in this reservation.
              // So, don't launch multiple instances with this demo code.
              System.out.println("Launching instance " + instanceId);
              return instanceId;
          } catch (Exception e)
          {
              // Simple exception handling by printing out error message and stack trace
              System.out.println(e.getMessage());
              e.printStackTrace();
              return "ERROR";
          }
      }
  </code></pre>
  
  <p>But I get this error code:</p>
  
  <pre><code>The image id '[ami-fd9cecc7]' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: f85433c1-df4f-4105-bfe3-6f900eca6b70)
  com.amazonaws.AmazonServiceException: The image id '[ami-fd9cecc7]' does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidAMIID.NotFound; Request ID: f85433c1-df4f-4105-bfe3-6f900eca6b70)
      at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1275)
      at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:873)
      at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:576)
      at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:362)
  </code></pre>
  
  <p>Can you propose me some solution how to fix this code or there is a alternative?</p>
  
  <p>Can you recommend me some working solution which I can use?</p>