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

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

问题描述

我使用 ant 在 Eclipse 中创建 .jar 文件.效果很好.

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

我有一个正在处理的 .jar 文件,它希望代码位于 .jar 文件中(它在与 .jar 文件相同的目录中查找 .properties 文件)——标准的 Eclipse运行"和调试"菜单执行指定 Java 类的 main() 方法......但它们是从包含已编译类文件的目录中执行的,而不是 jar 文件.有没有办法改变这种行为,以便 Eclipse 运行来自适当的 .jar 文件的代码?

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?

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

(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.)

推荐答案

是的,您可以创建自定义的运行配置":
即,一个Java Application",带有:

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

  • Classpath 选项卡从其默认内容(.class 目录)中清空并添加了 jar
  • Source标签及其默认内容(应引用项目的src目录)
  • 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.

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

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

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