use of org.eclipse.jdt.launching.IVMInstall in project jop by jop-devel.
the class JOPizer method createJOPizeLaunchConfiguration.
private ILaunchConfiguration createJOPizeLaunchConfiguration(String programArguments) throws CoreException {
String configName = "JOPize";
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
for (ILaunchConfiguration config : configs) {
if (config.getName().equals(configName)) {
config.delete();
break;
}
}
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configName);
IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
Map attributes = workingCopy.getAttributes();
attributes.put(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "com.jopdesign.build.JOPizer");
attributes.put(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments);
IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
IPath jopTools = new Path(jopHome).append(new Path("java/tools/dist/lib/jop-tools.jar"));
IRuntimeClasspathEntry jopToolsEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopTools);
jopToolsEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
IPath jopClasses = new Path(jopHome).append(new Path("java/target/dist/lib/classes.zip"));
IRuntimeClasspathEntry jopClassesEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopClasses);
jopClassesEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
// IClasspathEntry jreEntry = JavaRuntime.getDefaultJREContainerEntry();
List<String> classpath = new ArrayList<String>();
classpath.add(jopToolsEntry.getMemento());
classpath.add(jopClassesEntry.getMemento());
// classpath.add(jreEntry.get)
attributes.put(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
attributes.put(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
attributes.put(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmgci=false");
workingCopy.setAttributes(attributes);
System.err.printf("> %s%n", workingCopy.toString());
return workingCopy;
}
use of org.eclipse.jdt.launching.IVMInstall in project tdi-studio-se by Talend.
the class Tools method searchJdkRootDirectory.
/**
* Searches the JDK root directory.
*
* @return The JDK root directory, or empty string if not found
*/
private String searchJdkRootDirectory() {
// search from the JREs that are specified on preference page
for (IVMInstallType type : JavaRuntime.getVMInstallTypes()) {
for (IVMInstall install : type.getVMInstalls()) {
String jdkRootDirectory = install.getInstallLocation().getPath();
if (null == validateJdkRootDirectory(jdkRootDirectory)) {
Activator.log(IStatus.INFO, NLS.bind(Messages.jdkRootDirectoryFoundMsg, jdkRootDirectory), new Exception());
return jdkRootDirectory;
}
}
}
// search at the same directory as current JRE
String javaHome = System.getProperty(JAVA_HOME_PROPERTY_KEY);
for (File directory : getPossibleJdkRootDirectory(javaHome)) {
String path = directory.getPath();
if (null == validateJdkRootDirectory(path)) {
Activator.log(IStatus.INFO, NLS.bind(Messages.jdkRootDirectoryFoundMsg, path), new Exception());
return path;
}
}
Activator.log(IStatus.WARNING, Messages.jdkRootDirectoryNotFoundMsg, new Exception());
//$NON-NLS-1$
return "";
}
use of org.eclipse.jdt.launching.IVMInstall in project sling by apache.
the class DefaultJavaVMInstall method before.
@Override
protected void before() throws Throwable {
if (JavaRuntime.getDefaultVMInstall() != null) {
return;
}
String jreHome = System.getProperty("java.home");
File installLocation = new File(jreHome);
final IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(StandardVMType.ID_STANDARD_VM_TYPE);
// find an unused VM id
String id = null;
do {
id = String.valueOf(System.currentTimeMillis());
} while (vmInstallType.findVMInstall(id) != null);
VMStandin newVm = new VMStandin(vmInstallType, id);
newVm.setName("Default-VM");
newVm.setInstallLocation(installLocation);
IVMInstall realVm = newVm.convertToRealVM();
JavaRuntime.setDefaultVMInstall(realVm, new NullProgressMonitor());
// wait for the default vm reconfiguration to settle
// TODO - find something to poll agains rather than sleeping blindly
Thread.sleep(5000);
}
Aggregations