大型Java应用程序中的Eclipse远程调试.jar文件 [英] Eclipse remote debug .jar files inside a larger java application

查看:54
本文介绍了大型Java应用程序中的Eclipse远程调试.jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与远程调试有关的大多数问题都是针对整个Java应用程序的,您可以从中获得IDE上的代码.

Most of the questions related to remote debugging are for an entire java application from which you have the code on your IDE.

在这种情况下,我无权访问整个应用程序,只能访问.jar文件,这些代码后来又嵌入到较大的应用程序中,该应用程序最终将调用它们并执行其代码.

In this case I do not have access to the full application, only to pieces of code, .jar files, that are later on embedded into the larger application which eventually will invoke them and execute their code.

与大型应用程序不同,我开发的这些.jar文件不包含该方法:

Different from the large application, these .jar files that I develop do not contain the method:

public static void main(string [] args)

.jar文件实现了骆驼处理器接口,当每个配置需要特定的代码段时就会调用该接口.

The .jar files implement the camel Processor interface which is called when a particular piece of code is required per configuration.

我正在尝试仅为嵌入式.jar文件设置Eclipse远程调试.这意味着一旦调用.jar文件代码,eclipse IDE便会开始其调试过程.

I am trying to set up eclipse remote debugging for the embedded .jar files only. Meaning that once the .jar file code is invoked eclipse IDE would start its debugging process.

到目前为止我尝试过的事情:

What I tried so far:

我试图以调试模式启动.jar文件:

I tried to start the .jar file in debug mode:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y -jar mycode.jar

此后它开始:

Listening for transport dt_socket at address: 8000

尽管如上所述,这不是一个完整的Java应用程序,但是一旦我尝试将eclipse上的远程配置连接到它,我就会收到错误消息:

Although as stated above this is not a complete java application and once I try to connect the remote configuration on eclipse to it I get the error:

no main manifest attribute, in mycode.jar

如前所述,这对我来说很有意义,因为我没有主要课程.

as said before, this made sense to me because I don't have a main class.

现在,即使没有主类,也可以仅在调用.jar文件时调试它吗?

Now, is it possible to debug a .jar file only when it is called even if no main class is present?

推荐答案

我看到有四点需要注意:

I see four points to note:

1)如果没有代码,则无法在JARS内进行调试.您可以反编译JAR并尝试调试.请参阅我们如何调试内部文件Jar文件

1) If you don't have the code, you can't debug inside JARS. You could decompile the JAR and try to debug. See How can we debug a file which is inside Jar file

2)当然,如果您的应用程序不是桌面独立应用程序(Web服务,基于队列的应用程序等),则可以不使用主要方法进行调试.在这种情况下,您必须调用该服务,并且将调用(IDE已知的)代码,从而允许进行调试.仅当您具有项目的完整代码时才适用,该代码可能是较大应用程序的一部分.

2) Of course you can debug without a main method if your application is not a desktop standalone app (web service, queue-based app, etc). In that cases you must call the service and the (IDE-known) code will be called, allowing debugging. This applies only if you have the full code of the project, that could be part of a larger application.

3)如果只有一段代码(函数或某些类),则可以构建一个单元测试(使用JUnit或某些其他软件)或设置所有必要值的主要方法,以获取正确的值程序流程.然后,执行单元测试或调试即可解决问题.

3) If you only have pieces of code (functions, or some classes), you can build a unit test (with JUnit or some other software) or a main method setting up ALL NECESSARY values, in order to get a correct program flow. Then, executing the unit test or debugging can do the trick.

4)--Xdebug允许JVM远程调试,而不是代码调试.意味着您不能在代码块中停下来,但基本上可以检查变量,性能规格等.

4) --Xdebug allows JVM remote debugging, not code debugging. Means you cannot stop in code blocks but basically allows to check the variables, performance specs and more.

这篇关于大型Java应用程序中的Eclipse远程调试.jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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