exception in thread 'main' java.lang.NoClassDefFoundError:

后端 未结 23 3483
心在旅途
心在旅途 2020-11-28 06:27

The following program is throwing error:

public class HelloWorld {
    public static void main(String args[]) {
        System.out.println(\"Hello World!\");         


        
23条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 06:39

    Exception in thread "main" java.lang.NoClassDefFoundError  
    

    One of the places java tries to find your .class file is your current directory. So if your .class file is in C:\java, you should change your current directory to that.

    To change your directory, type the following command at the prompt and press Enter:

    cd c:\java  
    

    This . tells java that your classpath is your local directory.

    Executing your program using this command should correct the problem:
    java -classpath . HelloWorld  
    

提交回复
热议问题