Q: How to compile and run a .java file which is set in a package? The K.java file
package com.mypackage;
public class K{
  public static void main(String[] args) {
    System.out.println("Hello at last!");
  }
}

Now I am an Ubuntu user so I open my terminal and try to compile with the javac command.
javac K.java

and it seems to be compiled cause I get a K.class file in the same directory.
The problem is when I am trying to run it with the java command.
java K

I get the following compiler error

Error: Could not find or load main class K

I also tried to run java com.mypackage.K but I am getting the same error. What am I missing? This should have been very simple right?
