title: how to create an object of a class in a different package in another class
body: <p>I am a beginner at java, I used to code in C++ and there when using classes I used to define them in separate files and then include those classes in my main file. </p>
  
  <p>I'm trying to learn threads for socket programming so I can open multiple server ports as threads and accept multiple clients. I know that in Java the file name should be the same as the class name (correct me if i am wrong). This is what I am trying to do:</p>
  
  <p><strong>main.java</strong></p>
  
  <pre><code>include derived.java;
  
  class main1 
  
  {
  
    main1() 
  
          {
  
               System.out.println("Constructor of main1 class.");
  
          }
  
    void main1_method() 
          {
  
               System.out.println("method of  main 1 class");
          }
  
    public static void main(String[] args) 
  
          {
  
               main1 my = new main1();
               Derived derivedThread = new Derived();
               derivedThread.start();
  
          }
  }
  </code></pre>
  
  <p><strong>derived.java</strong></p>
  
  <pre><code>public class derived extends Thread 
  
      {       
              public void run()
  
              {
  
                  System.out.println("starting a new thread");
  
      }
  
      } 
  </code></pre>
  
  <p>How can I create a derived class object in main and include it in my main1.java file?</p>
  
  <p>I think I do not fully understand how classes work in Java and what classpath has to be used with it. I have a deadline for my networking project and I am very behind so please help me! </p>