I've got the following piece of code:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
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.ui.DebugUITools;
public class Main {
public static void main(String... strings) throws IOException {
try {
String path = "E:\\Java\\Projects\\.metadata\\.plugins\\org.eclipse.debug.core\\.launches\\MedicineFrame.launch";
ILaunchManager launchManager = DebugPlugin.getDefault()
.getLaunchManager();
ILaunchConfigurationType type = launchManager
.getLaunchConfigurationType(ILaunchManager.RUN_MODE);
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(
null, path);
workingCopy.setAttribute("PATH_MY", path);
ILaunchConfiguration configuration = workingCopy.doSave();
DebugUITools.launch(configuration, ILaunchManager.RUN_MODE);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
Actually, I just want to run the launch configuration specified in the file defined by absolute path. I receive an NPE, because the DebugPlugin.getDefault() returns null. What should I do? I've found a lot of similar examples, but none of them tells about the NPE, like no one has ever got it before me.