Reputation: 1652
I have a java program with multiple class files and they are all stored in the same folder called lab7. I coded the project in NetBeans so used "package lab7" in all the files. My main application java file is called lab7.java. Now, when i try to run this on the terminal i get "Exception in main thread: NoClassDefFoundError". I do the following inside the folder lab7.
javac *.java
java lab7
I don't know why get this error. It should be some basic class path error. Thanks for the help.
Upvotes: 2
Views: 5648
Reputation: 3380
Use
java lab7.lab7
You do have a lab7.java file with a public static void main(String[]) method, right?
Upvotes: 0
Reputation: 222973
Normally class names should start with a capital letter. So you should rename your main class to Main
. If it's inside the lab7
package, run this:
java lab7.Main
This should be run in the directory that contains the lab7
directory. So if you're in the lab7
directory itself, go up one level first.
Upvotes: 2