2

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.

2
  • Here's more info. on using Java from the command line: kevinboone.net/classpath.html Commented Apr 24, 2011 at 18:20
  • If you have not set classpaths and whatnot you can do java -classpath . lab7 after you have javac'd it, assuming you are in the same directory Commented Jun 28, 2017 at 8:43

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Use

java lab7.lab7

You do have a lab7.java file with a public static void main(String[]) method, right?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.