我正在尝试运行一个简单的java测试代码。我得到一个“找不到或加载主类文件”(类似的东西)。
我正在学习的教程使用以下命令
-> javac name.java (javac doesn't work, using ->java ..)
-> dir (shows the classname as a file)
> java classname
> outputs "hello world"我好像过不了->java running.java
class apples //everything begins with a class - need this to do anything
{
public static void main(String args[])//method
{
System.out.println("Hello World");
}
}发布于 2012-10-05 15:40:58
class Apples //- need this to do anything
{
public static void main(String args[])//everything begins with a method
{
System.out.println("Hello World");
}
}请确保您位于java文件的当前目录中。
编译为
javac Apples.java运行方式
java Apples在使用它之前,应该知道编码约定,最好使用java。
发布于 2012-10-05 07:39:10
井。在Jaca中,您所要做的就是导航到存储类文件的位置,然后使用java的“类名”。您不需要放入.java或.class。只是名字而已。
发布于 2012-10-05 15:26:15
将您的类名从Apple改为apples ( java类名的命名约定):http://en.wikipedia.org/wiki/Naming_convention_%28programming%29#Java
还建议您相应地更改文件名...
然后重新编译并运行它
javac Apples.java
java Apples
干杯
https://stackoverflow.com/questions/12740045
复制相似问题