Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Debugging an eclipse application running programmatically
Debugging an eclipse application running programmatically [message #1832649] Tue, 22 September 2020 16:48 Go to next message
Miroslav Shipilov is currently offline Miroslav ShipilovFriend
Messages: 2
Registered: September 2020
Junior Member

I have simple example of my app:
package plugin;


public class MyActivator implements IApplication  {
	public Object start(IApplicationContext context) throws Exception {
		for (int i=0 ; i < 10 ; i++) {
			System.out.println("MyActivator " + i);	
		return null;
	public void stop() {

In my test I create a startup configuration for this app and launch it, then do all sorts of checks

Example test:
package test;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
import org.junit.Test;

public class MyTest { 
	boolean isStart;
	public void test1() throws CoreException, InterruptedException, IOException {
			ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
			   ILaunchConfigurationType type =
			ILaunchConfigurationWorkingCopy workingCopy =
			      type.newInstance(null, "Start java");
			workingCopy.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS","-os ${target.os} -ws ${} -arch ${target.arch} -nl ${} -consoleLog -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:52245");

			ILaunchConfiguration configuration = workingCopy.doSave();
			ILaunch laucnh = configuration.launch(ILaunchManager.DEBUG_MODE, null);

			laucnh.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {
				public void streamAppended(String text, IStreamMonitor monitor) {
					System.out.println("APP INFO " + text);
			for (int start = 0; start < 10; start++) {
				if (isStart) {

The main question is how can I debug the application when running the test since it runs in a separate process? "Remote java application" doesn't help.
Re: Debugging an eclipse application running programmatically [message #1833540 is a reply to message #1832649] Fri, 16 October 2020 09:51 Go to previous message
Miroslav Shipilov is currently offline Miroslav ShipilovFriend
Messages: 2
Registered: September 2020
Junior Member
I found a solution. In the startup configuration, add the VM arguments "-vmargs -Xdebug -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=" + port;". and set ILaunchManager.RUN_MODE. Using Launch group to launch Remote server in Listener mode and the test.
Previous Topic:MyEclipse Related Java Projects
Next Topic:Selected string not delete while type new string.
Goto Forum:

Current Time: Mon Jun 27 09:10:08 GMT 2022

Powered by FUDForum. Page generated in 0.01943 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top