I assume you want to be able to use step-through debugging from Eclipse. You can just run the classes externally by setting the built classes in the bin directories on the JRE classpath.
java -cp workspacep1in;workspacep2in foo.Main
You can debug using the remote debugger and taking advantage of the class files built in your project.
In this example, the Eclipse project structure looks like this:
workspaceproject
.classpath
.project
debug.bat
inMain.class
srcMain.java
1. Start the JVM Console in Debug Mode
debug.bat is a Windows batch file that should be run externally from a cmd.exe console.
@ECHO OFF
SET A_PORT=8787
SET A_DBG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=%A_PORT%,server=y,suspend=y
java.exe %A_DBG% -cp .in Main
In the arguments, the debug port has been set to 8787. The suspend=y argument tells the JVM to wait until the debugger attaches.
2. Create a Debug Launch Configuration
In Eclipse, open the Debug dialog (Run > Open Debug Dialog...) and create a new Remote Java Application configuration with the following settings:
- Project: your project name
- Connection Type: Standard (Socket Attach)
- Host: localhost
- Port: 8787
3. Debugging
So, all you have to do any time you want to debug the app is:
- set a break point
- launch the batch file in a console
- launch the debug configuration
You can track this issue in bug 122429. You can work round this issue in your application by using an abstraction layer as described here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…