title: Find the Public IP of all my EC2 instances using Java?
body: <p>I am trying to get the Public IP of all my Amazon Ec2 instances using the Java SDK. I have been searching through the <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html" rel="nofollow">documentation</a> and found that I need to use a <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html?com/amazonaws/services/ec2/package-summary.html" rel="nofollow">DescribeInstanceRequest</a>, <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/DescribeInstancesResult.html" rel="nofollow">DescribeInstanceResult</a> and a <a href="http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/ec2/model/Filter.html" rel="nofollow">Filter</a> to achieve my purpose.  </p>
  
  <p>However, I do not understand how to complete the circle. The DescribeInstanceResult does not seem to have what I need and I do not know how to effectively print the instance IPs that I want. </p>
  
  <p>So far, this is my code:</p>
  
  <pre><code>public List&lt;String&gt; getPublicIPs(){
          DescribeInstancesRequest request =  new DescribeInstancesRequest();
          request.setInstanceIds(instanceIds);
  
          List&lt;Filter&gt; filters = new LinkedList&lt;Filter&gt;();
          filters.add(new Filter("ip-address"));
          request.setFilters(filters);
  
  
          DescribeInstancesResult result = ec2.describeInstances(request);
  
          //what now!?
          return null;
      }
  </code></pre>
  
  <p>How do I complete it? What am I missing?</p>