1 11 package org.eclipse.jdt.internal.launching; 12 13 14 import java.io.File ; 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.core.runtime.NullProgressMonitor; 21 import org.eclipse.core.runtime.SubProgressMonitor; 22 import org.eclipse.debug.core.DebugPlugin; 23 import org.eclipse.debug.core.ILaunch; 24 import org.eclipse.debug.core.model.IProcess; 25 import org.eclipse.jdt.launching.IVMInstall; 26 import org.eclipse.jdt.launching.JavaRuntime; 27 import org.eclipse.jdt.launching.LibraryLocation; 28 import org.eclipse.jdt.launching.VMRunnerConfiguration; 29 30 33 public class Standard11xVMRunner extends StandardVMRunner { 34 35 public Standard11xVMRunner(IVMInstall vmInstance) { 36 super(vmInstance); 37 } 38 39 42 public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException { 43 44 if (monitor == null) { 45 monitor = new NullProgressMonitor(); 46 } 47 48 IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1); 49 subMonitor.beginTask(LaunchingMessages.StandardVMRunner_Launching_VM____1, 2); 50 subMonitor.subTask(LaunchingMessages.StandardVMRunner_Constructing_command_line____2); 52 String program= constructProgramString(config); 53 54 List arguments= new ArrayList (); 55 arguments.add(program); 56 57 String [] vmArgs= combineVmArgs(config, fVMInstance); 60 addArguments(vmArgs, arguments); 61 62 String [] bootCP= config.getBootClassPath(); 63 String [] classPath = config.getClassPath(); 64 65 String [] combinedPath = null; 66 if (bootCP == null) { 67 LibraryLocation[] locs = JavaRuntime.getLibraryLocations(fVMInstance); 68 bootCP = new String [locs.length]; 69 for (int i = 0; i < locs.length; i++) { 70 bootCP[i] = locs[i].getSystemLibraryPath().toOSString(); 71 } 72 } 73 74 combinedPath = new String [bootCP.length + classPath.length]; 75 int offset = 0; 76 for (int i = 0; i < bootCP.length; i++) { 77 combinedPath[offset] = bootCP[i]; 78 offset++; 79 } 80 for (int i = 0; i < classPath.length; i++) { 81 combinedPath[offset] = classPath[i]; 82 offset++; 83 } 84 85 if (combinedPath.length > 0) { 86 arguments.add("-classpath"); arguments.add(convertClassPath(combinedPath)); 88 } 89 arguments.add(config.getClassToLaunch()); 90 91 String [] programArgs= config.getProgramArguments(); 92 addArguments(programArgs, arguments); 93 94 String [] cmdLine= new String [arguments.size()]; 95 arguments.toArray(cmdLine); 96 97 if (monitor.isCanceled()) { 99 return; 100 } 101 102 subMonitor.worked(1); 103 subMonitor.subTask(LaunchingMessages.StandardVMRunner_Starting_virtual_machine____3); 104 105 Process p= null; 106 File workingDir = getWorkingDir(config); 107 p= exec(cmdLine, workingDir); 108 if (p == null) { 109 return; 110 } 111 112 if (monitor.isCanceled()) { 114 p.destroy(); 115 return; 116 } 117 118 IProcess process= DebugPlugin.newProcess(launch, p, renderProcessLabel(cmdLine)); 119 process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine)); 120 subMonitor.worked(1); 121 } 122 } 123 124 | Popular Tags |