×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / 请教一个Java编译的问题。
    Java在后台打出未被catch的Exception的时候,会显示例如:
    Exception in thread "main" java.lang.ClassCastException
    然后是出错代码在哪个类的哪个方法的哪一行。但有时不显示出行数,而显示“Compiled Code"。我以前以为只有在该行代码被放在try{}中时才会这样。但现在我的程序除了在main()的行数显示了外,其他接下来几层调用都说是“Compiled Code”,但我都没放在try{}里面。请问在如何能让它显示Exception的确切行数?或者说在什么情况下会出现“Compiled Code”?

    我用JDK1.2.2,在Dos下用Javac和Java编译和运行。不知道出错在哪一行找错太麻烦了。
    • Did you use the Exception.printStackTrace() method?
      If not, use it like this way:

      try {
      ....
      } catch (Exception e) {
      e.printStackTrace(System.out);
      }
      • 这个没用。Catch了Exception后打出来的和不Catch由系统自己打出来的是一样的一段话。还是说是Compiled Code。
    • 高手都睡觉了吗?
    • i remember there's a debugger in forte which is free for download in java.sun.com. jbulider and visual cafe should also have their own debuggers...
    • Print your code
    • The easiest solution is install Sun's JDK 1.3.x. If you have to use 1.2.2, then use runtime option to set java.compiler to NONE.