Eclipse : Switching Perspectives Programatically

Here is how you can switch to a Perspective programatically:


Display.getDefault().asyncExec(new Runnable(){
public void run(){
IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry();
String perspId = "id of perspective you want to switch to";
w.getActivePage().setPerspective(reg.findPerspectiveWithId(perspId));
}
});


If you want to for example swithc to debug perspective when your custom launch configuration is launched, put this code at the end of your launch delegate.