eclipse:如何将Java程序调试为.jar文件? [英] eclipse: how to debug a Java program as a .jar file?

查看:109
本文介绍了eclipse:如何将Java程序调试为.jar文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ant 在Eclipse中创建.jar文件。工作非常好。



我有一个.jar文件,我正在处理这个文件,期望代码位于.jar文件中(它在同一目录中查找.properties文件作为.jar文件) - 标准的Eclipse运行和调试菜单执行指定的Java类的 main()方法,但他们这样做从包含编译的类文件的目录,而不是一个jar文件。有没有办法改变这个行为,所以Eclipse从适当的.jar文件运行代码?



(我现在的解决办法是在外面运行.jar文件,它暂停等待调试器,根据 Dave Ray对我的其他问题之一的回答。)

$ b $是的,您可以创建一个自定义的运行配置

即, Java应用程序一个,其中:




  • Classpath 标签从其默认内容( .class 目录)中清空,并添加了jar。

  • 来源选项卡及其默认内容(应参考项目的 src 目录)



可以运行或调试一个这样的配置。





使用jars作为用户条目的自定义配置示例


I use ant for creating .jar files in Eclipse. Works great.

I have a .jar file I am working on that expects the code to be in a .jar file (it looks for .properties files in the same directory as the .jar file) -- the standard Eclipse "Run" and "Debug" menus execute the main() method of a specified Java class... but they do it from the directory containing the compiled class files, not a jar file. Is there a way to change this behavior so Eclipse runs code from the appropriate .jar file instead?

(My workaround right now is to run the .jar file externally, with it suspended waiting for a debugger, per Dave Ray's answer to one of my other questions.)

解决方案

Yes, you can create a custom "Run Configuration":
Ie, a "Java Application" one, with:

  • Classpath tab emptied from its default content (the .class directory) and with the jar added
  • Source tab with its default content (should reference the src directory of the project)

One such configuration can be run or debugged.

(Example of a custom configuration with jars as user entries)

这篇关于eclipse:如何将Java程序调试为.jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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