Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (6.1k points)

I am new to Java. So I wrote a program on FileManagement and I wanted to run it through the command line. I can compile it through cmd with javac FileManagement/*.java which is creating all of the classes in that folder but when I try java FileManagement.Main 

There it displays: 

Exception in thread "main" java.lang.NoClassDefFoundError: FileManagement/Main

I tried it on a remote computer and worked fine but could not run it on my system.

1 Answer

0 votes
by (11.7k points)

In case your Main class is in FileManagement Package on Linux, then try the following:

java -cp . FileManagement.Main

in the parent folder of the FileManagement folder.

And if your main class is not located in a package then cd to the FileManagement folder and try the following:

java -cp . Main

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...