简体   繁体   中英

running java file from command prompt

I made simple hello world app Java file. I tried to compile it on command prompt in windows and went very well. but when I try to run it with Java the command prompt says the following error. Error: Could not find or load main class "Project Name". but when I checked the folder the file "Project Name".class is existed moreover I have main in it.

why I get this error ?

Edit :

file name : HelloWorldApp.java

code :

package helloworldapp;
/** * The HelloWorldApp class implements an application that 
    * simply prints "Hello World!" to standard output. */ 

public class HelloWorldApp
{ /* * @param args the command line arguments */
    public static void main(String[] args)
    { 
        System.out.println("Hello World!"); // Display the string
    } 
}

尝试在运行时将当前目录添加到类路径中,并包括程序包名称

java -cp . helloworldapp.HelloWorldApp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM