gpt4 book ai didi

java - 为什么我的程序不能在 javac 编译器中运行,但可以在 IDE 中运行

转载 作者:行者123 更新时间:2023-12-01 18:12:11 24 4
gpt4 key购买 nike

这是一个简单的程序,应该在 10 分钟内完成。但是这个错误不断出现,告诉 javac 编译器在解析时已到达文件末尾。但是当我在 IDE(Net beans)中运行相同的事情时。我得到结果了。

  public class beerbottlesong
{
public static void main (String[] args){
int x=99;//value given to no. of beer bottles
while(x>0)//starting while loop
{
System.out.println (x + "bottles of beer on the wall" + x + " bottles of beer.");

System.out.println ("Take one down and pass it around, " + (x-1) + " bottles of beer on the wall");
x--;//decrementing the value of beer bottles

}//end while loop

}//end main method

}//error occured in javac -reached end of file while parsing

最佳答案

这在 javac 编译器中运行良好。

确保使用命令

javac FileName.java

java FileName

请将类名命名为BeerBottleSong,请遵循正确的命名约定。

<小时/>

如果您仍然无法运行程序,请确保您已设置类路径。

关于java - 为什么我的程序不能在 javac 编译器中运行,但可以在 IDE 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32162950/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com