title: Import own class file in .java
body: <p>Hey an question i have this compiled .class file that contains in the .java file this:</p>
  
  <pre><code>package my.mypackage;
  public class MyClass {
  //SPACE START
      public static void space(int spacecount) {
      int spacepos = 1;
          while (spacepos &lt;= spacecount) {
              System.out.println("");
              spacepos++;
          }
      }
  //SPACE END
  //HASH START
      public static int encrypt(String pass) {
          int total = 0;
          int  countone = 0;
          int  counttwo = 0;
          String charlist = "abcdefghiklmnopqrstuvwxyz";
          for (int l = 0; l &lt; pass.length(); l++) {
              countone = pass.charAt(l);
              counttwo = (charlist.indexOf(countone));
              counttwo++;
              total *= 17;
              total += counttwo; 
          }
          return total;
      }
  //HASH END
  }
  </code></pre>
  
  <p>and i want to to import it into an other file named a.java it contains this:</p>
  
  <pre><code>import my.mypackage.MyClass;
  import java.util.Scanner;
  public class a {
      public static void main(String[] args) {
          MyClass.space(4);
          Scanner in = new Scanner();
          System.out.println("Input pass: ");
          String a = in.nextLine();
          int b = MyClass.encrypt(a);
          MyClass.space(4);
          System.out.println(b);
  
      }
  }
  </code></pre>
  
  <p></p>
  
  <p>both are in one folder.
  but when im trying to compile it it shows me this: </p>
  
  <pre><code>a.java:1: error: package my.mypackage does not exist                                                                                                                                  
  import my.mypackage.MyClass;                                                                                                                                                          
                     ^                         
  a.java:5: error: cannot access MyClass                                                                                                                                                
                  MyClass.space(4);                                                                                                                                                     
                  ^                                                                                                                                                                     
    bad class file: ./MyClass.class                                                                                                                                                     
      class file contains wrong class: my.mypackage.MyClass                                                                                                                             
      Please remove or make sure it appears in the correct subdirectory of the classpath.                                                                                               
  2 errors           
  </code></pre>
  
  <p>can anyone show me how to bring it together step by step ?</p>