title: How can I run a java.class from Main Activity
body: <p>I'm a beginner at Android Development and hoping someone can help me a bit out.</p>
  <p>I want to connect to a local server (IP). I found a code in GitHub that supposedly would do this connection. But the thing is that this is a <code>java.class</code> and not in my <code>MainActivity</code>. So when I run my app in the emulator now, nothing happens. How can I run the <code>Java.class</code> from inside my <code>MainActivity</code>?</p>
  <p>Here is the source: <a href="https://github.com/calimero-project/introduction/tree/master/src/main/java" rel="nofollow noreferrer">https://github.com/calimero-project/introduction/tree/master/src/main/java</a></p>
  <p>Class:</p>
  <pre><code>public class CreateTunnelingLink
  {
  
      /**
       * Local endpoint, replace the IP address with your actual address. The local socket address is important for
       * multi-homed clients (several network interfaces), or if the address via InetAddress.getLocalHost is not useful.
       */
      private static final InetSocketAddress local = new InetSocketAddress(&quot;192.168.10.13&quot;, 3671);
  
      /**
       * Specifies the KNXnet/IP server to access the KNX network, insert your server's actual host name or IP address,
       * e.g., &quot;192.168.1.20&quot;. The default port is where most servers listen on for new connection requests.
       */
      private static final InetSocketAddress server = new InetSocketAddress(&quot;myKnxServer.myHome&quot;,
              KNXnetIPConnection.DEFAULT_PORT);
  
      public static void main(final String[] args)
      {
          System.out.println(&quot;This example establishes a tunneling connection to the KNXnet/IP server &quot; + server);
  
          // A KNX tunneling link supports NAT (Network Address Translation) if required.
          // We also indicate that the KNX installation uses twisted-pair (TP) medium, with TP1 being the most common.
          // KNXNetworkLink is the base interface implemented by all supported Calimero links to a KNX network.
          try (KNXNetworkLink knxLink = KNXNetworkLinkIP.newTunnelingLink(local, server, false, TPSettings.TP1)) {
              System.out.println(&quot;Connection established to server &quot; + knxLink.getName());
              System.out.println(&quot;Close connection again&quot;);
          }
          catch (KNXException | InterruptedException e) {
              // KNXException: all Calimero-specific checked exceptions are subtypes of KNXException
  
              // InterruptedException: longer tasks that might block are interruptible, e.g., connection procedures. In
              // such case, an instance of InterruptedException is thrown.
              // If a task got interrupted, Calimero will clean up its internal state and resources accordingly.
              // Any deviation of such behavior, e.g., where not feasible, is documented in the Calimero API.
  
              System.out.println(&quot;Error creating KNXnet/IP tunneling link: &quot; + e);
          }
      }
  }
  
  </code></pre>
  <p>MainActivity:</p>
  <pre><code>
  public class MainActivity extends AppCompatActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
  
  }
  </code></pre>