How to specify the classpath for the JDI launch connector; using Eclipse?

I am doing essentially the same thing as the original poster of this question . In my case, I am trying to run the Sun / Oracle JPDA Sample Applications in Eclipse Kepler on OS X 10.8.5 with Oracle jdk1.7.0_72. However, the documentation for these examples seems to suggest that they will be run from the command line.

I want to use com.sun.jdi.connect.LaunchingConnector to run debuggee program. It requires the arguments of the Map <String, Argument> class. One of the map entries has the key "main", and the associated object contains a string that is the name of the main debuggee class. In my case, this is "debuggee.DebuggerTest". The launcher has a main class "debugger.TraceLaunch".

My Eclipse project has a default structure, so there is a folder named "classes" with a subfolder for each package. In my case, these are "com", "debugger" and "debuggee". The "com" package includes all the classes from the " JDI Application Samples ".

I am using the VMLauncher "referenced in the above entry to start. The startup fails; it reports that my main class" debuggee.DebuggerTest "was not found. It also fails if I try to include the full path as part of my main name class.

If I open a terminal and export the CLASSPATH variable that points to the "classes" folder inside my Eclipse project (and JDI libraries), I can start debuggee with the java debuggee.DebuggerTest command and work correctly. I can also start the debugger using the java debugger.TraceLaunch command and in turn launches the debuggee successfully. This suggests that VMLauncher is doing everything right.

It looks like the problem is that somewhere deep in the example packages or JDI packages from Oracle "tools.jar", LaunchingConnector is causing the command line to start. It seems to be the SunCommandLineLauncher class. This launcher seems to assume a class path. The launcher arguments don't seem to be documented, so I don't know if there is an option to specify the classpath. The source code for the Oracle jdk1.7.0 JDA classes (in "lib / tools.jar") has apparently not been published, so I cannot look at the code for details of how the launcher uses its arguments.

Another clue you might find useful is that in the sample JDI applications, the sample GUI debugger allows you to specify the classpath it is trying to parse. Unfortunately, it does not recognize quotation marks or character escaping like the UNIX shell does, and it does not understand folder names that contain a space character.

Ideally, I would like to know how to specify the path to the LaunchingConnector class.

My second choice would be some more general guidance on how to specify the classpath when adapting a command line program to run in Eclipse.

+3


source to share


1 answer


The new VM created by Trace has a different classpath. If you want to run the program in eclipse you need to add the following code to your tracing program.

Connector.Argument options =(Connector.Argument)arguments.get("options");
options.setValue("-cp \"F:\\Workspace\\TraceProgram\\bin\"");

      



Where -cp sets the classpath to the newly created virtual machine, you need to change to the eclipse working directory.

This worked for me.

+4


source







All Articles