title: accessing variable from parent class
body: <p>gameServer.java:</p>
  
  <pre><code>import java.util.ArrayList;
  
  public class gameServer{
  
      public static server server;
      public static gameRunner gameRunner;
      public static ArrayList&lt;packet&gt; packets = new ArrayList&lt;packet&gt;();
  
      public static void main(String[] args) throws Exception {
          server = new server();
          server.startServer(5050);
          Runnable listenServer = new Runnable() {
              public void run() {
                  while(true) {
                      packets.add(server.getPacket());
                  }
              }
          };
          new Thread(listenServer).start();
          gameRunner = new gameRunner();
          while(true) {
              if(packets.size() &lt;= 0)
                  continue;
              gameRunner.executeMessage(packets.get(0));
              packets.remove(0);
          }
      }
  }
  </code></pre>
  
  <p>server.js:</p>
  
  <pre><code>import java.net.*;
  import java.util.Date;
  
  public class server {
  
      public static DatagramSocket socketServer;
      private Date date = new Date();
  
      public void startServer (int port) throws SocketException {
          socketServer = new DatagramSocket(port);
          System.out.println("Started Server on port: " + port);
      }
  public void sendPacket (packet packet) {
          String message = null;
          for(int i = 0; i &lt; packet.header.length; i++) {
              message += packet.header[i] + "\r\n";
          }
          message += "\r\n" + packet.message;
          String[] info = packet.address.split(":");
          try {
              sendPacket(message, (Inet4Address)InetAddress.getByName(info[0]), Integer.parseInt(info[1]));
          } catch (Exception e) {
              System.out.println("failed to determine host");
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>gameRunner.js:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Date;
  
  
  public class gameRunner {
  
      public static ArrayList&lt;object&gt; objects = new ArrayList&lt;object&gt;();
      public static player[] players = new player[1000];
  
      public Date date = new Date();
  
      Runnable updatePlayers = new Runnable() {
          public void run () {
              while(true) {
                  long StartTime = date.getTime();
                  for(int i = 0; i &lt; players.length; i++) {
                      if(players[i] == null)
                          continue;
                      players[i].updatePos();
                  }
                  while(StartTime + 100 &lt; date.getTime()) { }
              }
          }
      };
  
      Runnable sendPlayerPackets = new Runnable () {
          public void run () {
              while(true) {
                  parent.gameServer.sendPacket(player[0].packet); //&lt;&lt;&lt;----
                  }
          }
      };
  
  }
  </code></pre>
  
  <p>I am new to classes, abstract, inherent and such. I need to be able to access socketServer object in gameServer from gameRunner to send a message. I am not sure how to do this, thanks in advance.</p>