KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > exports > BuildUtilities


1 /*******************************************************************************
2  * Copyright (c) 2006 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.pde.internal.core.exports;
12
13 import org.eclipse.jdt.launching.IVMInstall;
14 import org.eclipse.jdt.launching.JavaRuntime;
15 import org.eclipse.jdt.launching.LibraryLocation;
16 import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
17 import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
18
19 public class BuildUtilities {
20     
21     public static String JavaDoc getBootClasspath() {
22         return getBootClasspath(JavaRuntime.getDefaultVMInstall());
23     }
24
25     public static String JavaDoc getBootClasspath(String JavaDoc environmentID) {
26         IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
27         IExecutionEnvironment environment = manager.getEnvironment(environmentID);
28         IVMInstall vm = null;
29         if (environment != null) {
30             vm = environment.getDefaultVM();
31             if (vm == null) {
32                 IVMInstall[] installs = environment.getCompatibleVMs();
33                 // take the first strictly compatible vm if there is no default
34
for (int i = 0; i < installs.length; i++) {
35                     IVMInstall install = installs[i];
36                     if (environment.isStrictlyCompatible(install)) {
37                         vm = install;
38                         break;
39                     }
40                 }
41                 // use the first vm failing that
42
if (vm == null && installs.length > 0) {
43                     vm = installs[0];
44                 }
45             }
46         }
47         if (vm == null)
48             vm = JavaRuntime.getDefaultVMInstall();
49         return getBootClasspath(vm);
50     }
51
52     public static String JavaDoc getBootClasspath(IVMInstall install) {
53         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
54         LibraryLocation[] locations = JavaRuntime.getLibraryLocations(install);
55         for (int i = 0; i < locations.length; i++) {
56             buffer.append(locations[i].getSystemLibraryPath().toOSString());
57             if (i < locations.length - 1)
58                 buffer.append(";"); //$NON-NLS-1$
59
}
60         return buffer.toString();
61     }
62
63 }
64
Popular Tags