【发布时间】:2015-06-02 12:17:16
【问题描述】:
我是一名新的Java学生 我在命令提示符下运行 hello world 程序,但出现错误
class hello{
public static void main(String agrs[]){
system.out.println("Hello world");
}
}
这是我的hello world程序
G:\java>javac hello.java
G:\java>dir
Volume in drive G has no label.
Volume Serial Number is 32DF-BA6B
Directory of G:\java
14-Sep-13 04:36 PM <DIR> .
14-Sep-13 04:36 PM <DIR> ..
14-Sep-13 04:36 PM 415 hello.class
14-Sep-13 04:35 PM 100 hello.java
2 File(s) 515 bytes
2 Dir(s) 55,645,966,336 bytes free
G:\java>java hello
Error: Could not find or load main class hello
我的java路径是对的
G:\java>path
PATH=G:\Windows\system32;G:\Windows;G:\Windows\System32\Wbem;G:\Windows\System32
\WindowsPowerShell\v1.0\;G:\Program Files\Java\jdk1.7.0_25\bin
但是什么时候使用这个命令然后程序运行。
G:\java>java -classpath . hello
Hello world
我想问一下为什么我的程序不能正常运行是我的路径设置变量有问题吗?我想正常运行我的程序
G:\java>java hello
【问题讨论】:
-
你确定你的程序编译成功了吗?
system.out.println("Hello world");这一行有错误(假设发帖时不是错字) -
它是 main(String[] args),你有 main(String args[]) 并且系统应该是 System.out.println()
-
你的答案在这里:eclipse.org/downloads
-
你检查你的类路径环境变量了吗?类路径与路径无关。
-
@RyanHurling
main(String[] args)在这里不是问题。
标签: java