本文整理汇总了Java中org.eclipse.jdt.launching.JavaRuntime.getDefaultVMInstall方法的典型用法代码示例。如果您正苦于以下问题:Java JavaRuntime.getDefaultVMInstall方法的具体用法?Java JavaRuntime.getDefaultVMInstall怎么用?Java JavaRuntime.getDefaultVMInstall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.launching.JavaRuntime
的用法示例。
在下文中一共展示了JavaRuntime.getDefaultVMInstall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVMInstall
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
protected IVMInstall getVMInstall() {
IVMInstall vmInstall = null;
// Try using the very same VM the Toolbox is running with (e.g.
// this avoids problems when the Toolbox runs with a 64bit VM, but
// the nested VM is a 32bit one).
final String javaHome = System.getProperty("java.home");
if (javaHome != null) {
final IVMInstallType installType = new StandardVMType();
vmInstall = installType.createVMInstall("TLCModelCheckerNestedVM");
vmInstall.setInstallLocation(new File(javaHome));
return vmInstall;
}
// get OS default VM (determined by path) not necessarily the same
// the toolbox is running with.
return JavaRuntime.getDefaultVMInstall();
}
示例2: getVMInstall
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public IVMInstall getVMInstall() {
if (getVMInstallTypeId() == null)
return JavaRuntime.getDefaultVMInstall();
try {
IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
int size = vmInstalls.length;
String id = getVMInstallId();
for (int i = 0; i < size; i++) {
if (id.equals(vmInstalls[i].getId()))
return vmInstalls[i];
}
}
catch (Exception e) {
// ignore
}
return null;
}
示例3: reformatJavaFiles
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Recursively find the .java files in the output directory and reformat them.
*
* @throws CoreException
*/
private static void reformatJavaFiles(File outDir) throws CoreException {
// If a default JRE has not yet been detected (e.g. brand new workspace),
// the compiler source compliance may be set to 1.3 (the default value from
// code). This is a problem because the generated files do not compile
// against 1.3 (e.g. they use annotations), and thus the formatting will not
// succeed. We work around this using a trick from the
// CompliancePreferencePage: Ensure there is a default JRE which in
// turn updates the compliance level.
JavaRuntime.getDefaultVMInstall();
List<File> javaFiles = ProjectResources.findFilesInDir(outDir, javaSourceFilter);
for (File file : javaFiles) {
ProjectResources.reformatJavaSource(file);
}
}
示例4: getDefaultEEName
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private String getDefaultEEName() {
IVMInstall defaultVM= JavaRuntime.getDefaultVMInstall();
IExecutionEnvironment[] environments= JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments();
if (defaultVM != null) {
for (int i= 0; i < environments.length; i++) {
IVMInstall eeDefaultVM= environments[i].getDefaultVM();
if (eeDefaultVM != null && defaultVM.getId().equals(eeDefaultVM.getId()))
return environments[i].getId();
}
}
String defaultCC=JavaModelUtil.VERSION_LATEST;
if (defaultVM instanceof IVMInstall2)
defaultCC= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVM, defaultCC);
for (int i= 0; i < environments.length; i++) {
String eeCompliance= JavaModelUtil.getExecutionEnvironmentCompliance(environments[i]);
if (defaultCC.endsWith(eeCompliance))
return environments[i].getId();
}
return "JavaSE-1.7"; //$NON-NLS-1$
}
示例5: addClassPathEntries
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public void addClassPathEntries() {
try {
final ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
final IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] _libraryLocations = JavaRuntime.getLibraryLocations(vmInstall);
final Consumer<LibraryLocation> _function = new Consumer<LibraryLocation>() {
@Override
public void accept(final LibraryLocation eachLocation) {
IPath _systemLibraryPath = eachLocation.getSystemLibraryPath();
IClasspathEntry _newLibraryEntry = JavaCore.newLibraryEntry(_systemLibraryPath, null, null);
entries.add(_newLibraryEntry);
}
};
((List<LibraryLocation>)Conversions.doWrapArray(_libraryLocations)).forEach(_function);
int _size = entries.size();
IClasspathEntry[] _newArrayOfSize = new IClasspathEntry[_size];
IClasspathEntry[] _array = entries.<IClasspathEntry>toArray(_newArrayOfSize);
this.javaProject.setRawClasspath(_array, null);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例6: is50OrHigherJRE
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Checks if the JRE of the given project or workspace default JRE have source compliance 1.5 or
* greater.
*
* @param project the project to test or <code>null</code> to test the workspace JRE
* @return <code>true</code> if the JRE of the given project or workspace default JRE have
* source compliance 1.5 or greater.
* @throws CoreException if unable to determine the project's VM install
*/
public static boolean is50OrHigherJRE(IJavaProject project) throws CoreException {
IVMInstall vmInstall;
if (project == null) {
vmInstall= JavaRuntime.getDefaultVMInstall();
} else {
vmInstall= JavaRuntime.getVMInstall(project);
}
if (!(vmInstall instanceof IVMInstall2))
return true; // assume 1.5.
String compliance= getCompilerCompliance((IVMInstall2) vmInstall, null);
if (compliance == null)
return true; // assume 1.5
return compliance.startsWith(JavaCore.VERSION_1_5)
|| compliance.startsWith(JavaCore.VERSION_1_6)
|| compliance.startsWith(JavaCore.VERSION_1_7);
}
示例7: createRuntime
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
private static IRuntime createRuntime(String runtimeName, String location,
IProgressMonitor progressMonitor) throws CoreException {
IRuntimeWorkingCopy runtime = null;
String type = null;
String version = null;
String runtimeId = null;
org.eclipse.core.runtime.IPath jbossAsLocationPath = new Path(location);
IRuntimeType runtimeTypes[] = ServerUtil.getRuntimeTypes(type, version,
"org.eclipse.jst.server.tomcat.runtime.60");
if (runtimeTypes.length > 0) {
runtime = runtimeTypes[0].createRuntime(runtimeId, progressMonitor);
runtime.setLocation(jbossAsLocationPath);
if (runtimeName != null)
runtime.setName(runtimeName);
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_ID",
defaultVM.getId());
((RuntimeWorkingCopy) runtime).setAttribute("PROPERTY_VM_TYPE_ID",
defaultVM.getVMInstallType().getId());
return runtime.save(false, progressMonitor);
} else {
return runtime;
}
}
示例8: createProject
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* This method creates a new java project based on the user inputs, captured in WizardInput object.
* The new project is created in the current workspace.
* @param wizardInput
* @return IJavaProject
* @throws CoreException
* @throws IOException
**/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(wizardInput.getProjectName());
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
IFolder binFolder = project.getFolder("bin");
binFolder.create(false, true, null);
javaProject.setOutputLocation(binFolder.getFullPath(), null);
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation element : locations) {
entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
}
InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
IFile jarFile = project.getFile("soot-trunk.jar");
jarFile.create(is, false, null);
IPath path = jarFile.getFullPath();
entries.add(JavaCore.newLibraryEntry(path, null, null));
javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
IFolder sourceFolder = project.getFolder("src");
sourceFolder.create(false, true, null);
IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
javaProject.setRawClasspath(newEntries, null);
String filepath = sourceFolder.getLocation().toOSString();
File file = new File(filepath);
wizardInput.setFile(file);
try {
CodeGenerator.generateSource(wizardInput);
} catch (JClassAlreadyExistsException e) {
e.printStackTrace();
}
sourceFolder.refreshLocal(1, null);
javaProject.open(null);
return javaProject;
}
示例9: start
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
// Initalizes the compliance options to include the default VM's compliance level.
JavaRuntime.getDefaultVMInstall();
}
示例10: getVMInstall
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
*
* @return
*/
public IVMInstall getVMInstall() {
final IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
for (final IVMInstallType vmType : vmTypes) {
final IVMInstall[] vms = vmType.getVMInstalls();
for (final IVMInstall vm : vms) {
if (vm.getId().equals(WeblogicPlugin.getDefault().getJRE())) {
return vm;
}
}
}
return JavaRuntime.getDefaultVMInstall();
}
示例11: configureVM
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public boolean configureVM() throws CoreException {
String javaHome = preferenceManager.getPreferences().getJavaHome();
if (javaHome != null) {
File jvmHome = new File(javaHome);
if (jvmHome.isDirectory()) {
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
File location = defaultVM.getInstallLocation();
if (!location.equals(jvmHome)) {
IVMInstall vm = findVM(jvmHome);
if (vm == null) {
IVMInstallType installType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
long unique = System.currentTimeMillis();
while (installType.findVMInstall(String.valueOf(unique)) != null) {
unique++;
}
String vmId = String.valueOf(unique);
VMStandin vmStandin = new VMStandin(installType, vmId);
String name = StringUtils.defaultIfBlank(jvmHome.getName(), "JRE");
vmStandin.setName(name);
vmStandin.setInstallLocation(jvmHome);
vm = vmStandin.convertToRealVM();
}
JavaRuntime.setDefaultVMInstall(vm, new NullProgressMonitor());
JDTUtils.setCompatibleVMs(vm.getId());
return true;
}
}
}
return false;
}
示例12: testDefaultVM
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
@Test
public void testDefaultVM() throws CoreException {
String oldJavaHome = prefManager.getPreferences().getJavaHome();
IVMInstall oldVm = JavaRuntime.getDefaultVMInstall();
assertNotNull(oldVm);
try {
IVMInstall vm = null;
IVMInstallType type = JavaRuntime.getVMInstallType(TestVMType.VMTYPE_ID);
IVMInstall[] installs = type.getVMInstalls();
for (IVMInstall install : installs) {
if (!install.equals(oldVm)) {
vm = install;
break;
}
}
assertNotNull(vm);
assertNotEquals(vm, oldVm);
String javaHome = new File(TestVMType.getFakeJDKsLocation(), "9").getAbsolutePath();
prefManager.getPreferences().setJavaHome(javaHome);
boolean changed = server.configureVM();
IVMInstall defaultVM = JavaRuntime.getDefaultVMInstall();
assertTrue("A VM hasn't been changed", changed);
assertEquals(vm, defaultVM);
assertNotEquals(oldVm, defaultVM);
} finally {
prefManager.getPreferences().setJavaHome(oldJavaHome);
TestVMType.setTestJREAsDefault();
}
}
示例13: isRuntimeJar
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public static boolean isRuntimeJar(File jar) throws IOException {
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation library : locations) {
File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile();
if(runtime.equals(jar.getCanonicalFile())){
return true;
}
}
return false;
}
示例14: getRuntimeJar
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
public static File getRuntimeJar(String jarName) throws IOException {
IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
for (LibraryLocation library : locations) {
File runtime = JavaCore.newLibraryEntry(library.getSystemLibraryPath(), null, null).getPath().toFile().getCanonicalFile();
if(runtime.getName().equals(jarName)){
return runtime;
}
}
return null;
}
示例15: setDefaultCompilerComplianceValues
import org.eclipse.jdt.launching.JavaRuntime; //导入方法依赖的package包/类
/**
* Sets the default compiler compliance options based on the current default JRE in the
* workspace.
*
* @since 3.5
*/
private void setDefaultCompilerComplianceValues() {
IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
if (defaultVMInstall instanceof IVMInstall2 && isOriginalDefaultCompliance()) {
String complianceLevel= JavaModelUtil.getCompilerCompliance((IVMInstall2)defaultVMInstall, JavaCore.VERSION_1_4);
Map<String, String> complianceOptions= new HashMap<String, String>();
JavaModelUtil.setComplianceOptions(complianceOptions, complianceLevel);
setDefaultValue(PREF_COMPLIANCE, complianceOptions.get(PREF_COMPLIANCE.getName()));
setDefaultValue(PREF_PB_ASSERT_AS_IDENTIFIER, complianceOptions.get(PREF_PB_ASSERT_AS_IDENTIFIER.getName()));
setDefaultValue(PREF_PB_ENUM_AS_IDENTIFIER, complianceOptions.get(PREF_PB_ENUM_AS_IDENTIFIER.getName()));
setDefaultValue(PREF_SOURCE_COMPATIBILITY, complianceOptions.get(PREF_SOURCE_COMPATIBILITY.getName()));
setDefaultValue(PREF_CODEGEN_TARGET_PLATFORM, complianceOptions.get(PREF_CODEGEN_TARGET_PLATFORM.getName()));
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:ComplianceConfigurationBlock.java