01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.core.exports;
11:
12: import org.eclipse.jdt.launching.IVMInstall;
13: import org.eclipse.jdt.launching.JavaRuntime;
14: import org.eclipse.jdt.launching.LibraryLocation;
15: import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
16: import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
17:
18: public class BuildUtilities {
19:
20: public static String getBootClasspath() {
21: return getBootClasspath(JavaRuntime.getDefaultVMInstall());
22: }
23:
24: public static String getBootClasspath(String environmentID) {
25: IExecutionEnvironmentsManager manager = JavaRuntime
26: .getExecutionEnvironmentsManager();
27: IExecutionEnvironment environment = manager
28: .getEnvironment(environmentID);
29: IVMInstall vm = null;
30: if (environment != null) {
31: vm = environment.getDefaultVM();
32: if (vm == null) {
33: IVMInstall[] installs = environment.getCompatibleVMs();
34: // take the first strictly compatible vm if there is no default
35: for (int i = 0; i < installs.length; i++) {
36: IVMInstall install = installs[i];
37: if (environment.isStrictlyCompatible(install)) {
38: vm = install;
39: break;
40: }
41: }
42: // use the first vm failing that
43: if (vm == null && installs.length > 0) {
44: vm = installs[0];
45: }
46: }
47: }
48: if (vm == null)
49: vm = JavaRuntime.getDefaultVMInstall();
50: return getBootClasspath(vm);
51: }
52:
53: public static String getBootClasspath(IVMInstall install) {
54: StringBuffer buffer = new StringBuffer();
55: LibraryLocation[] locations = JavaRuntime
56: .getLibraryLocations(install);
57: for (int i = 0; i < locations.length; i++) {
58: buffer.append(locations[i].getSystemLibraryPath()
59: .toOSString());
60: if (i < locations.length - 1)
61: buffer.append(";"); //$NON-NLS-1$
62: }
63: return buffer.toString();
64: }
65:
66: }
|