This will probably be flagged as duplicate but I have gone through a lot of answers in SOF and none of them worked for me. I had a Java project to which I added Maven nature, and since then I cannot run any Java file. Upon running (with -Xdiag) it says,
    Error: Could not find or load main class main.HelloWorld
Caused by: java.lang.ClassNotFoundException: main.HelloWorld
java.lang.ClassNotFoundException: main.HelloWorld
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:466)
    at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:780)
    at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:675)
If I remove the Maven nature and run, it will run as expected, but when I add Maven, the issue is back again. so to my knowledge, it should not be an issue related to Java build path or compiler configuration. I am not sure what is the issue. I have tried updating the project multiple times. I have also downloaded Maven and added it to User Environment variables, if that makes a difference.
Additional information: This is my classpath file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
        <attributes>
            <attribute name="module" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="org.eclipse.jst.component.nondependency" value=""/>
        </attributes>
    </classpathentry>
    <classpathentry exported="true" kind="lib" path="C:/Users/Anubhab Giri/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.48/tomcat-embed-core-9.0.48.jar" sourcepath="C:/Users/Anubhab Giri/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.48/tomcat-embed-core-9.0.48-sources.jar">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
            <attribute name="maven.groupId" value="org.apache.tomcat.embed"/>
            <attribute name="maven.artifactId" value="tomcat-embed-core"/>
            <attribute name="maven.version" value="9.0.48"/>
            <attribute name="maven.scope" value="compile"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="output" path="bin"/>
</classpath>
This is my project file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>hello-world</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>
