1 11 package org.eclipse.jdt.internal.launching; 12 13 14 import java.io.File ; 15 import java.text.MessageFormat ; 16 import java.util.Map ; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.NullProgressMonitor; 20 import org.eclipse.debug.core.DebugPlugin; 21 import org.eclipse.debug.core.ILaunch; 22 import org.eclipse.debug.core.ILaunchConfiguration; 23 import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate; 24 import org.eclipse.jdt.launching.ExecutionArguments; 25 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 26 import org.eclipse.jdt.launching.IVMInstall; 27 import org.eclipse.jdt.launching.IVMRunner; 28 import org.eclipse.jdt.launching.VMRunnerConfiguration; 29 30 33 public class JavaLocalApplicationLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate { 34 35 38 public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { 39 40 if (monitor == null) { 41 monitor = new NullProgressMonitor(); 42 } 43 44 monitor.beginTask(MessageFormat.format("{0}...", new String []{configuration.getName()}), 3); if (monitor.isCanceled()) { 47 return; 48 } 49 50 monitor.subTask(LaunchingMessages.getString("JavaLocalApplicationLaunchConfigurationDelegate.Verifying_launch_attributes..._1")); 52 String mainTypeName = verifyMainTypeName(configuration); 53 54 IVMInstall vm = verifyVMInstall(configuration); 55 56 IVMRunner runner = vm.getVMRunner(mode); 57 if (runner == null) { 58 abort(MessageFormat.format(LaunchingMessages.getString("JavaLocalApplicationLaunchConfigurationDelegate.0"), new String []{vm.getName(), mode}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); } 60 61 File workingDir = verifyWorkingDirectory(configuration); 62 String workingDirName = null; 63 if (workingDir != null) { 64 workingDirName = workingDir.getAbsolutePath(); 65 } 66 67 String [] envp= DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration); 69 70 String pgmArgs = getProgramArguments(configuration); 72 String vmArgs = getVMArguments(configuration); 73 ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs); 74 75 Map vmAttributesMap = getVMSpecificAttributesMap(configuration); 77 78 String [] classpath = getClasspath(configuration); 80 81 VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath); 83 runConfig.setProgramArguments(execArgs.getProgramArgumentsArray()); 84 runConfig.setEnvironment(envp); 85 runConfig.setVMArguments(execArgs.getVMArgumentsArray()); 86 runConfig.setWorkingDirectory(workingDirName); 87 runConfig.setVMSpecificAttributesMap(vmAttributesMap); 88 89 runConfig.setBootClassPath(getBootpath(configuration)); 91 92 if (monitor.isCanceled()) { 94 return; 95 } 96 97 prepareStopInMain(configuration); 99 100 monitor.worked(1); 102 103 monitor.subTask(LaunchingMessages.getString("JavaLocalApplicationLaunchConfigurationDelegate.Creating_source_locator..._2")); setDefaultSourceLocator(launch, configuration); 106 monitor.worked(1); 107 108 runner.run(runConfig, launch, monitor); 110 111 if (monitor.isCanceled()) { 113 return; 114 } 115 116 monitor.done(); 117 } 118 } 119 120 | Popular Tags |