Error executing Java program : Could not find or load main class

This question already has an answer here:

  • What does “Could not find or load main class” mean? 39 answers

  • Your CLASSPATH isn't set (or isn't set correctly). From the Java tutorial,

    The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes.

    However, you can also specify a CLASSPATH to the java runtime with the -cp argument (also aliased to -classpath . A colon separated list of folders, and jar/zip files to search for class files.

    That's why

    java -cp . HelloWorld
    

    Allowed the JRE to find HelloWorld.class. You could also set CLASSPATH.

    链接地址: http://www.djcxy.com/p/54980.html

    上一篇: 运行Java Spring应用程序

    下一篇: 执行Java程序时出错:无法找到或加载主类