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

标签 java compiler-errors

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

相关文章:

java - Java-在getLegalMoves()中找不到符号

java - Android 和 AppEngine 网络服务 : Json. .. RPC、REST... Protocol Buffer ?

java - 如何在队列中使用Handler Postdelayed?

java - 错误 : Program type already present: com. rom4ek.arcnavigationview.R

dll - 使用 MinGw 在 Windows 上构建 Mlt 时出错。 undefined reference dlsym dlclose dlopen dlerror dlclose

c++ - c++ operator []可以使用多个参数很好地编译,有没有办法避免这种情况?

java - 如何将 Web 驱动程序实例传递给另一个类的方法

java - 缺少 Spring Reactive Web 应用程序 POST 请求正文

java - 缓存来自 RMI 的 POJO

c++ - 数组下标错误的类型 'int[int]'无效