title: How do I use Jconsole to connect to EC2?
body: <p>I am running Jconsole on my macbook and trying to connect to a linux terminal on ec2 that does not have graphics(only command line access).</p>
  
  <p>I run my code like this:</p>
  
  <pre><code>java -jar program.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9005 
  -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.remote.ssl=false
  </code></pre>
  
  <p>I read <a href="https://forums.aws.amazon.com/thread.jspa?threadID=43587" rel="nofollow">here</a> that there was a problem with accessing via EC2(after I had problems connecting) and the solution seemed to be '<code>java.rmi.server.hostname to the public hostname of the instance</code>' </p>
  
  <p>I'm a bit confused at how to do this.  I have tried two things, one to put it directly in my code(in the void static main section):</p>
  
  <pre><code>System.setProperty( "java.rmi.server.hostname" , "external_EC2_address" ); //in my real code I have the correct address here
  </code></pre>
  
  <p>The system accepted it(no errors when I created/uploaded runnable jar).  I also opened the firewall on my instance to allow all TCP traffic. No Luck. I tried the above statement also as a flag to launch to the program but still no luck.</p>
  
  <p>Any ideas how do this?</p>
  
  <p>UPDATE: This will show how green I am at Java, I got a step further(still doesn't work) but I realized putting the java -jar filename.jar and then the options didn't give me the same results as putting my -jar at the end of the command.  I tried that and the program tries to connect and then says connection failed(before it would just say it at the login screen right away).</p>