在 Eclipse 中调试 java 时如何显示变量值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40967824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to show variable values when debug java in Eclipse?
提问by Jster Shih
I debug a simple java application on Eclipse in debug as and step into java resource bundle which got interrupted exception in line construction.getCause
我在 Eclipse 上调试了一个简单的 java 应用程序,然后进入 java 资源包,该资源包在行 building.getCause 中得到了中断的异常
How do I trace each variable and express to see the values from java library? In j2ee, I can point mice at params, vars and assigned value from express, how do I see it in java application?
如何跟踪每个变量并表达以查看 java 库中的值?在 j2ee 中,我可以将鼠标指向 params、vars 和来自 express 的赋值,我如何在 java 应用程序中看到它?
Why it cannot find the resource MyBundle base for MyBundle_zh.properties under project src?
为什么在项目src下找不到MyBundle_zh.properties的资源MyBundle库?
Screen shot: https://plus.google.com/collection/UFuOlBhttps://lh3.googleusercontent.com/ibrMgi8udPlaAIvyvPKc4tE5Agw5SzXxi5yp0a3yZJA5zNkYymSPgFHUEsO_tD2HsDMUZzE2=w640-h360-p-rwThanks
屏幕截图:https://plus.google.com/collection/UFuOlB https://lh3.googleusercontent.com/ibrMgi8udPlaAIvyvPKc4tE5Agw5SzXxi5yp0a3yZJA5zNkYymSPgFHUEsO_tD2HsDMUZzE2=w640-h360-p-rw谢谢
回答by Eugene S
Eclipse has different Perspectives, you can switch them from Window -> Show Perspective. Each Perspective can have a different set of views. In you case, make sure that you have the Debug Perspective open and then (if you don't have it there already) do:
Eclipse 有不同的透视图,您可以从 Window -> Show Perspective 切换它们。每个透视图都可以有一组不同的视图。在您的情况下,请确保您打开了调试透视图,然后(如果您还没有它)执行以下操作:
Window -> Show View -> Variables
窗口 -> 显示视图 -> 变量
Then, when your execution stops on a set breakpoint, you will be able to inspect all the relevant variables in the "Variables" view.
然后,当您的执行在设置的断点处停止时,您将能够在“变量”视图中检查所有相关变量。
回答by nitind
Your Installed JREspreference page, project Java Build Paths, and launch configurations should not be using "c:\Program Files\Java\jdk1.7.0_04\jre". They should instead just point to "c:\Program Files\Java\jdk1.7.0_04", after which the Java platform sources will be shown and debugging features you expect will work more automatically.
您的已安装 JRE首选项页面、项目Java 构建路径和启动配置不应使用“c:\Program Files\Java\jdk1.7.0_04\jre”。相反,它们应该指向“c:\Program Files\Java\jdk1.7.0_04”,之后将显示 Java 平台源代码,并且您期望的调试功能将更自动地工作。

