//type= manager.getLaunchConfigurationType("org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType");
type= manager.getLaunchConfigurationType(CommonNames.SYSINFO_LAUNCH_CONFIG_TYPE);
}else{
type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
}
ILaunchConfiguration config = null;
// if the configuration already exists, delete it
ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
for (int i = 0; i < configurations.length; i++) {
if (configurations[i].getName().equals(name))
configurations[i].delete();
}
// else create a new one
if (config == null) {
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
proj.getProject().getName());
// current directory should be the project root
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
proj.getProject().getLocation().toString());
// use the suplied args
if((vmargs!=null)&&!(vmargs.equals(""))){
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmargs);
}
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
mainClass);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
args);
// saves the new config
config = wc.doSave();
}
ILaunch launch=config.launch(ILaunchManager.RUN_MODE, null);
config.delete();
return launch;
}