int port= SocketUtil.findUnusedLocalPort(null, 5000, 15000);
int port= SocketUtil.findUnusedLocalPort("", 5000, 15000);
	public VMRunnerResult run(VMRunnerConfiguration config) throws CoreException {		int port= SocketUtil.findUnusedLocalPort(null, 5000, 15000);		if (port == -1) {			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.noPort"), null)); //$NON-NLS-1$		}		String location= getJDKLocation(""); //$NON-NLS-1$		if ("".equals(location)) { //$NON-NLS-1$			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.noJDKHome"), null)); //$NON-NLS-1$		}		String program= location+File.separator+"bin"+File.separator+"java"; //$NON-NLS-2$ //$NON-NLS-1$		File javawexe= new File(program+"w.exe"); //$NON-NLS-1$		File javaw= new File(program+"w"); //$NON-NLS-1$				if (javaw.isFile()) 			program= javaw.getAbsolutePath();		else if (javawexe.isFile())			program= javawexe.getAbsolutePath();		Vector arguments= new Vector();		arguments.addElement(program);		String[] bootCP= config.getBootClassPath();		if (bootCP.length > 0) {			arguments.add("-Xbootclasspath:"+convertClassPath(bootCP)); //$NON-NLS-1$		} 				String[] cp= config.getClassPath();		if (cp.length > 0) {			arguments.add("-classpath"); //$NON-NLS-1$			arguments.add(convertClassPath(cp));		}		addArguments(config.getVMArguments(), arguments);		arguments.add("-Xdebug"); //$NON-NLS-1$		arguments.add("-Xnoagent"); //$NON-NLS-1$		arguments.add("-Djava.compiler=NONE"); //$NON-NLS-1$		arguments.add("-Xrunjdwp:transport=dt_socket,address=127.0.0.1:" + port); //$NON-NLS-1$		arguments.add(config.getClassToLaunch());		addArguments(config.getProgramArguments(), arguments);		String[] cmdLine= new String[arguments.size()];		arguments.copyInto(cmdLine);		ListeningConnector connector= getConnector();		if (connector == null) {			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.noConnector"), null)); //$NON-NLS-1$		}		Map map= connector.defaultArguments();		int timeout= fVMInstance.getDebuggerTimeout();				specifyArguments(map, port, timeout);		Process p= null;		try {			try {				connector.startListening(map);				try {					p= Runtime.getRuntime().exec(cmdLine);						} catch (IOException e) {					if (p != null) {						p.destroy();					}					throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.title"), e)); //$NON-NLS-1$				}						IProcess process= DebugPlugin.getDefault().newProcess(p, renderProcessLabel(cmdLine));				process.setAttribute(JavaRuntime.ATTR_CMDLINE, renderCommandLine(cmdLine));				//try {				//	Thread.currentThread().sleep(5000);				//} catch (InterruptedException e) {				//}				boolean retry= false;				do  {					try {						VirtualMachine vm= connector.accept(map);						setTimeout(vm);						IDebugTarget debugTarget= JDIDebugModel.newDebugTarget(vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false);						return new VMRunnerResult(debugTarget, new IProcess[] { process });					} catch (InterruptedIOException e) {						retry= fRetryQuery.queryRetry();					}				} while (retry);			} finally {				connector.stopListening(map);			}		} catch (IOException e) {			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.connect"), e)); //$NON-NLS-1$		} catch (IllegalConnectorArgumentsException e) {			throw new CoreException(createStatus(LauncherMessages.getString("jdkLauncher.error.connect"), e)); //$NON-NLS-1$		}		if (p != null)			p.destroy();		return null;	}