• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to resolve this error  RSS feed

 
Muneera Mujawar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could not find or load the main class.



Its compiling the compiled class is in C:\programs\class folder. Iam running the program using the following commands...
javac MainClass2.java // This is working fine

java -cp C:\programs\class MainClass2
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class is in a package - class files always needs to be in a directory structure that mirrors the package structure. Work through the relevant chapter of the Oracle Java Tutorial: https://docs.oracle.com/javase/tutorial/java/package/index.html (and bookmark the tutorial if you haven't done so yet, you will need it frequently).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!