在 Eclipse 中使用 ANT 脚本时如何调试 Java 代码 [英] How to debug Java code when using ANT script in Eclipse

查看:27
本文介绍了在 Eclipse 中使用 ANT 脚本时如何调试 Java 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 java 类,我需要调试它(放置断点并继续使用 F6).我正在使用 ANT 脚本来初始化、构建、部署和运行代码.我正在使用:

I have a java class and I need to debug it (put breakpoints and continue using F6). I am using ANT script to init, build, deploy and run the code. I am using:

<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,vars,source">

..........

</javac>

但是当我将断点放在我的 foo.java 类中的一行中并运行 ant 脚本(运行部分,右键单击运行-->Debug As-->Ant Build)时,Eclipse 不会停止在那行代码.

But when I place the breakpoint in a line in my foo.java class and I run the ant script (the run part, Right Click on run-->Debug As-->Ant Build), Eclipse does not stop at that line of code.

我错过了什么?!

推荐答案

ant 任务中你应该添加两个 jvm 参数(IIRC) 开启调试:

In the <java> ant task you should add two jvm parameters (<jvmarg> IIRC) to turn on debugging:

 -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5432

这将在调试打开的情况下启动 java 程序,该程序将准备好接受端口 5432 上的调试器连接.然后您应该使用 IDE 的远程调试工具并将其引导到端口 5432.

This will launch the java program with debugging turned on and the program will be ready to accept debugger connections on port 5432. Then you should use your IDE's remote debugging facility and direct it to connect to port 5432.

这篇关于在 Eclipse 中使用 ANT 脚本时如何调试 Java 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆