这是一个简单的程序,应该在 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/