Home

Jobs

Blogs

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?
Verwin Posted Date Posted on 18/8/2020
Verwin Count 9 Answers
Verwin User Default Image Gerald Warp Verwin Posted DateAnswered on 16/9/2020
While executing, when JVM does not find a .class file with the specified name then a run time error occurs saying “Could not found or load main class”. The reason why this happens is mostly due to:

Wrong Class Name
Invalid Classpath

Main class could not be found when there is typo or wrong syntax in the fully qualified java class name or it does not exist in the provided classpath. You must ensure that you add the location of your .class file to your classpath. So, if its in the current folder, add . to your classpath. Note that the Windows classpath separator is a semi-colon ; .  If you want to execute the main() method in MainClass, you must use the full class name, including package name, in the java command.

http://net-informations.com/java/cjava/default.htm

Verwin Piyush Govil Piyush Govil Verwin Posted DateAnswered 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 Pankaj Motiani Verwin Posted DateAnswered on 20/8/2020
In the above mentioned error you have not defined the main class, cause the main class is the 1 which Java calls as soon as program is run.

You just need to define your function under
-------
public static void main (string []args)
{
         // Define your code over here
}
Verwin User Default Image Ramanjaneyulu Ramanjaneyulu Verwin Posted DateAnswered 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 Verwin Posted DateAnswered 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 Tousif Iqbal Verwin Posted DateAnswered on 20/8/2020
Use exact class name instead .class file.check and resolve syntax error ,otherwise If the classpath environment variable where Java searches for all the class files does not have the main class, this error is shown.
Verwin User Default Image Apoorv Singh Verwin Posted DateAnswered 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 Verwin Posted DateAnswered 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 Verwin Posted DateAnswered 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?
While executing, when JVM does not find a .class file with the specified name then a run time error occurs saying “Could not found or load main class”. The reason why this happens is mostly due to:

Wrong Class Name
Invalid Classpath

Main class could not be found when there is typo or wrong syntax in the fully qualified java class name or it does not exist in the provided classpath. You must ensure that you add the location of your .class file to your classpath. So, if its in the current folder, add . to your classpath. Note that the Windows classpath separator is a semi-colon ; .  If you want to execute the main() method in MainClass, you must use the full class name, including package name, in the java command.

http://net-informations.com/java/cjava/default.htm

Verwin User Default Image
Answered on: 16/9/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
In the above mentioned error you have not defined the main class, cause the main class is the 1 which Java calls as soon as program is run.

You just need to define your function under
-------
public static void main (string []args)
{
         // Define your code over here
}
Verwin User Default Image
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
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
Use exact class name instead .class file.check and resolve syntax error ,otherwise If the classpath environment variable where Java searches for all the class files does not have the main class, this error is shown.
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