我无法运行Java程序 [英] I can't run a Java program
问题描述
我开始学习Java。我按照教程介绍了如何安装它。
我还通过在cmd中键入javac(不带引号)来检查它是否有效。是的,它提供了一个完整的文本列表,这意味着它应该工作,对吗?
I was starting to learn Java. I followed the tutorial on how to install it. I also checked by typing "javac"(without the quotation marks) in cmd if it works. And yes it gives a whole list of text which means its supposed to work, right?
这是我的java代码:
This is my java code:
class apples{
public static void main(String args[]) {
System.out.printIn("hello youtube");
}
}
我将其保存在名为'test'的文件夹中我的车。
这是我在cmd中输入的内容:
I saved it in a folder called 'test' in my c drive. This is what I typed in cmd:
cd \
dir
现在它列出了我的c盘中的所有内容,其中一个是测试
cd test
dir
现在它列出了测试中的所有内容,其中一个是' youtube.java
'(我命名的文件),所以我输入
Now it lists everything in test and one of them is 'youtube.java
'(the file I named), so I type
javac youtube.java
这不起作用
这就是它给我的:
This doesn't work This is what it gives me:
youtube.java:3:错误:找不到符号< br>
System.out.printIn(hello youtube);
symbol:method printIn(string)
location:变量类型PrintStream
1错误
youtube.java:3: error: cannot find symbol
System.out.printIn("hello youtube");
symbol: method printIn(string)
location: variable out of type PrintStream
1 error
有人能帮帮我吗?
推荐答案
你的通话中有拼写错误。更改
You have a typo in your call. Change
System.out.printIn("hello youtube"); // capital 'I'
到
System.out.println("hello youtube"); // lowercase 'l'
如前所述,在Java中,文件中的public
类必须与文件名匹配。
And as has been mentioned already, in Java, the public
class in a file must match the filename.
这篇关于我无法运行Java程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!