<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sakshii</title>
    <description>The latest articles on DEV Community by Sakshii (@sakshii1).</description>
    <link>https://dev.to/sakshii1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F743059%2F71df161c-8772-4479-8894-b409c2633346.jpeg</url>
      <title>DEV Community: Sakshii</title>
      <link>https://dev.to/sakshii1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sakshii1"/>
    <language>en</language>
    <item>
      <title>HOW TO FIX “ERROR: COULD NOT FIND OR LOAD MAIN CLASS” IN JAVA?</title>
      <dc:creator>Sakshii</dc:creator>
      <pubDate>Tue, 02 Nov 2021 10:44:09 +0000</pubDate>
      <link>https://dev.to/sakshii1/how-to-fix-error-could-not-find-or-load-main-class-in-java-2k23</link>
      <guid>https://dev.to/sakshii1/how-to-fix-error-could-not-find-or-load-main-class-in-java-2k23</guid>
      <description>&lt;p&gt;The main() method is required to run/execute programs developed in the Java programming language since it is where the program execution begins. When starting a &lt;a href="https://www.codeleaks.io/category/java/"&gt;Java&lt;/a&gt; program, you could encounter the warning “error: Could not find or load main class.” You’re having this problem because you’re using the java command to run main() from within the class.&lt;/p&gt;

&lt;p&gt;Note: You can also learn Errors and Exception in &lt;a href="https://www.codeleaks.io/category/python/"&gt;Python&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to fix could not find or load the main class?&lt;/strong&gt;&lt;br&gt;
There are many ways to solve this issue depending on the reason of occurring this error. We will discuss each reason one by one and try to fix this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the possible causes or reasons of this error?&lt;/strong&gt;&lt;br&gt;
There are several reasons for this problem, which are listed below.&lt;/p&gt;

&lt;p&gt;File Extension&lt;br&gt;
Wrong Package&lt;br&gt;
Classpath is not valid&lt;br&gt;
The class name is incorrect&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File Extension&lt;/strong&gt;&lt;br&gt;
We need to save the Java source code file with the extension .java to compile it. To compile a Java program, Java Compiler is being used as (javac command). After compilation, the .java file will be converted to a .class file.&lt;/p&gt;

&lt;p&gt;As a result, your source code file will end in.java, while the produced file will end in .class. For compiling source code, we were using filename, but for running a compiled file, we cannot use the file name but the class name. Else it will throw an error like in the below example.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: HelloWorld.java&lt;/strong&gt;&lt;br&gt;
public class HelloWorld {&lt;br&gt;
    public static void main(String[] args) {&lt;br&gt;
        System.out.println("Hello, World!");&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
