Could not find or load main class

后端 未结 16 1072
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 20:27

I have Windows 7, installed jdk1.7.0 and its supporting jre7.
My problem is compilation part works perfectly, but while running the Java program I get this error saying:

相关标签:
16条回答
  • 2020-11-27 20:55

    You might have the CLASSPATH environment variable already added!!

    Use following to avoid further usage of -cp . in java -cp . CLASSFILE

    Add . to CLASSPATH in system properties->environment variables or by cmd

    set CLASSPATH=%CLASSPATH%;.;

    0 讨论(0)
  • 2020-11-27 20:55

    If you have a single .java file to compile using command-line , then remove topmost package parts from the code, the compile again, it will work.

    This worked for me.

    0 讨论(0)
  • 2020-11-27 20:56

    Check you class name first. It should be p1 as per your batch file instruction. And then check you package of that class, if it is inside any package, specify when you run.

    If package is x.y

    java x.y.p1
    
    0 讨论(0)
  • 2020-11-27 20:57

    i guess that you have a different class name in p1.java

    0 讨论(0)
提交回复
热议问题