Verwin J Vinothkanna J
Home

Jobs

Blogs

Profile

Contact us
Verwin Forum Ask Question
Verwin User Default Image
I'm new to java and i seem to be getting this error : "Could not find or load main class ..." Can someone explain how to solve this and why this problem occurs?
 Posted on 18/8/2020
10 Answers
Verwin User Default Image Sanju Sanjana Answered on 19/11/2020

Check if you have given the correct syntax for the main function

See if your code is properly compiled.

If u had any issues in compiling also, this could happen in an IDE like eclipse

Verwin Piyush Govil Piyush Govil Answered on 21/8/2020Expert
This error usually occurs when you are trying to run your java program using java command as main class but java is unable to find the class.
To solve this you must try to familiarise with how java loads classes. 
Usually it occurs because of incorrect CLASSPATH. 
You will be able to find lot of guidance on how to set classpath directory online. Learn how its done and how java loads classes. You should be able to solve the issue quickly.
Verwin User Default Image Ramanjaneyulu Ramanjaneyulu Answered on 20/8/2020
-> save the file name same as class name otherwise you get " Could not find or load main class ...".
Verwin User Default Image Kiran Joshi Answered on 20/8/2020
1.) Set the Environment variables path if you have just before.
2.) Check the path of the file which you are executing.
3.)Use the classname while executing with java command.
Verwin User Default Image Apoorv Singh Answered on 20/8/2020
First check the name of class you typed is correct or not and if its ok then check the package. Mostly this issue comes due to the wrong name of package, so make sure your class is in the right package and command you are giving is also right.
Verwin Nitesh Agrawal Nitesh Agrawal Answered on 20/8/2020
Use the classname while executing with java command not the name by which you save the java file. 
Verwin User Default Image Deepshikha Pandey Answered on 20/8/2020
Can you show me that error
I'm new to java and i seem to be getting this error : "Could not find or load main class ..." Can someone explain how to solve this and why this problem occurs?

Check if you have given the correct syntax for the main function

See if your code is properly compiled.

If u had any issues in compiling also, this could happen in an IDE like eclipse

Verwin User Default Image
Answered on: 19/11/2020
This error usually occurs when you are trying to run your java program using java command as main class but java is unable to find the class.
To solve this you must try to familiarise with how java loads classes. 
Usually it occurs because of incorrect CLASSPATH. 
You will be able to find lot of guidance on how to set classpath directory online. Learn how its done and how java loads classes. You should be able to solve the issue quickly.
Verwin Piyush Govil
Answered on: 21/8/2020
-> save the file name same as class name otherwise you get " Could not find or load main class ...".
Verwin User Default Image
Answered on: 20/8/2020
1.) Set the Environment variables path if you have just before.
2.) Check the path of the file which you are executing.
3.)Use the classname while executing with java command.
Verwin User Default Image
Answered on: 20/8/2020
First check the name of class you typed is correct or not and if its ok then check the package. Mostly this issue comes due to the wrong name of package, so make sure your class is in the right package and command you are giving is also right.
Verwin User Default Image
Answered on: 20/8/2020
Use the classname while executing with java command not the name by which you save the java file. 
Verwin Nitesh Agrawal
Answered on: 20/8/2020
Can you show me that error
Verwin User Default Image
Answered on: 20/8/2020