KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > launching > StandardVM


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.launching;
12
13
14 import java.io.File JavaDoc;
15
16 import org.eclipse.debug.core.ILaunchManager;
17 import org.eclipse.jdt.launching.AbstractVMInstall;
18 import org.eclipse.jdt.launching.IVMInstallType;
19 import org.eclipse.jdt.launching.IVMRunner;
20
21 public class StandardVM extends AbstractVMInstall {
22     StandardVM(IVMInstallType type, String JavaDoc id) {
23         super(type, id);
24     }
25     /* (non-Javadoc)
26      * @see org.eclipse.jdt.launching.IVMInstall#getVMRunner(java.lang.String)
27      */

28     public IVMRunner getVMRunner(String JavaDoc mode) {
29         if (ILaunchManager.RUN_MODE.equals(mode)) {
30             return new StandardVMRunner(this);
31         } else if (ILaunchManager.DEBUG_MODE.equals(mode)) {
32             return new StandardVMDebugger(this);
33         }
34         return null;
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.jdt.launching.IVMInstall#getJavaVersion()
39      */

40     public String JavaDoc getJavaVersion() {
41         StandardVMType installType = (StandardVMType) getVMInstallType();
42         File JavaDoc installLocation = getInstallLocation();
43         if (installLocation != null) {
44             File JavaDoc executable = StandardVMType.findJavaExecutable(installLocation);
45             if (executable != null) {
46                 String JavaDoc vmVersion = installType.getVMVersion(installLocation, executable);
47                 // strip off extra info
48
StringBuffer JavaDoc version = new StringBuffer JavaDoc();
49                 for (int i = 0; i < vmVersion.length(); i++) {
50                     char ch = vmVersion.charAt(i);
51                     if (Character.isDigit(ch) || ch == '.') {
52                         version.append(ch);
53                     } else {
54                         break;
55                     }
56                 }
57                 if (version.length() > 0) {
58                     return version.toString();
59                 }
60             }
61         }
62         return null;
63     }
64 }
65
Popular Tags