I am stock this problem for a while. And finally I find my anser via follwing link: http://stackoverflow.com/questions/631682/help-with-packages-in-java-import-does-not-work Okay, just to clarify things that have already been posted. You should have the directory com , containing the directory company , containing the directory example , containing the file MyClass.java . From the folder containing com , run: $ javac com\company\example\MyClass.java Then: $ java com.company.example.MyClass Hello from MyClass! These must both be done from the root of the source tree. Otherwise, javac and java won't be able to find any other packages (in fact, java wouldn't even be able to run MyClass ). A short example I created the folders "testpackage" and "testpackage2". Inside testpackage, I created TestPackageClass.java containing the following code: package testpackage ; import testpackage2 . MyClass ; publi...