Search code examples
javapackaging

Exception in thread "main" java.lang.NoClassDefFoundError: (wrong name


my project is in "\BankPrj" folder It has

(1).com folder

(2)Account.java,Customer.java,TestBanking.java files

(3) main class is in TestBanking.java

this is the error..

enter image description here

this is my complete project

https://docs.google.com/folder/d/0BzMe2Ya7vhrAem5rcEljc3k1cFE/edit

pls correct the errors.

i executed TestBanking.class from test folder itself.


Solution

  • Your package is com.mybank.test

    The way you should invoke is that go to Folder BankPrj.

    now do java -classpath . com.mybank.test.TestBanking

    This should work now.

    Remember, you cannot go into the leaf of the folder to execute your class. You should always stay at the root (when using the package) and execute with fully qualified package name and the class name to execute it.

    Hope this helps!