Package org.eclipse.jdt.launching

Examples of org.eclipse.jdt.launching.IVMInstall


     */
    public static ILaunch launchApacheDS( LdapServer server, IPath apacheDsLibrariesFolder, String[] libraries )
        throws Exception
    {
        // Getting the default VM installation
        IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();

        // Creating a new editable launch configuration
        ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager()
            .getLaunchConfigurationType( IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION );
        ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null,
            NLS.bind( Messages.getString( "LdapServersUtils.Starting" ), new String[] //$NON-NLS-1$
                { server.getName() } ) );

        // Setting the JRE container path attribute
        workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmInstall
            .getInstallLocation().toString() );

        // Setting the main type attribute
        workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
            "org.apache.directory.studio.apacheds.Launcher" ); //$NON-NLS-1$
View Full Code Here


  /*
   * (non-Javadoc)
   * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getVMRunner(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
   */
  public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException {
    IVMInstall launcher = VMHelper.createLauncher(configuration);
    return launcher.getVMRunner(mode);
  }
View Full Code Here

    private void launchApacheDS()
    {
        try
        {
            // Getting the default VM installation
            IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();

            // Creating a new editable launch configuration
            ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(
                IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION );
            ILaunchConfigurationWorkingCopy workingCopy = type.newInstance( null, "Starting " + server.getName() );

            // Setting the JRE container path attribute
            workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmInstall
                .getInstallLocation().toString() );

            // Setting the main type attribute
            workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
                "org.apache.directory.studio.apacheds.Launcher" );
View Full Code Here

  protected void saveJreInRuntime(IRuntimeWorkingCopy wc) {
    IKarafRuntimeWorkingCopy srt = (IKarafRuntimeWorkingCopy) wc.loadAdapter(
        IKarafRuntimeWorkingCopy.class, new NullProgressMonitor());
    if( srt != null ) {
      IExecutionEnvironment selectedEnv = jreComposite.getSelectedExecutionEnvironment();
      IVMInstall selectedVM = jreComposite.getSelectedVM();
      srt.setVM(selectedVM);
      srt.setExecutionEnvironment(selectedEnv);
    }
  }
View Full Code Here

    }
    return null;
  }
 
  public IVMInstall getVM() {
    IVMInstall hard = getHardVM();
    if( hard == null )
      return VMInstallUtil.findVMInstall(getExecutionEnvironment());
    return hard;
  }
View Full Code Here

    java.setProject(antProject);
    java.setClassname(mainClass);
    java.setFork(true);

    // use the project configured jvm if possible
    IVMInstall jvm = JavaRuntime.getVMInstall(javaProject);
    if (jvm != null){
      String path = jvm.getInstallLocation() + "/bin/java";
      if (Os.isFamily(Os.FAMILY_WINDOWS)){
        path += ".exe";
      }
      if (new File(path).exists()){
        java.setJvm(path);
View Full Code Here

  {
    String jarName = Os.isFamily(Os.FAMILY_MAC) ? "classes.jar" : "rt.jar";
    // doing a straight JavaCore.setClasspathVariable() doesn't work, so we need
    // to modify the library path of the default vm install.
    try{
      IVMInstall vm = JavaRuntime.getDefaultVMInstall();
      LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vm);
      LibraryLocation[] newLocations = new LibraryLocation[locations.length];
      for(int ii = 0; ii < locations.length; ii++){
        IPath libraryPath = locations[ii].getSystemLibraryPath();

        // eclipse didn't find src.zip, so search other known locations.
        if (libraryPath.lastSegment().equals(jarName) &&
            (locations[ii].getSystemLibrarySourcePath().isEmpty() ||
             !locations[ii].getSystemLibrarySourcePath().toFile().exists()))
        {
          IPath jreSrc = null;

          logger.debug("Attempting to locate jre src.zip for JAVA_HOME: {}",
              SystemUtils.JAVA_HOME);
          for (int jj = 0; jj < SRC_LOCATIONS.length; jj++){
            String location = SRC_LOCATIONS[jj];

            // absolute path
            if (location.startsWith("/") ||
                location.indexOf(':') != -1)
            {
              jreSrc = new Path(location);

            // relative path
            }else{
              jreSrc = libraryPath.removeLastSegments(3).append(location);
            }

            logger.debug("Trying location: {}", jreSrc);
            if(jreSrc.toFile().exists()){
              break;
            }
          }

          // other possibilities on windows machines:
          // library path: C:/.../jre<version>/
          // src archive:  C:/.../jdk<version>/src.zip
          //   or
          // library path: C:/.../jre<major>/
          // src archive:  C:/.../jdk1.<major>.<minor>_<patch>/src.zip
          if (!jreSrc.toFile().exists() && Os.isFamily(Os.FAMILY_WINDOWS)){
            String path = libraryPath.toOSString()
              .replaceFirst("\\\\(lib\\\\)rt.jar", "");

            // first scenerio
            String altHome = path.replaceFirst(
                "jre(\\d+\\.\\d+\\.\\d+_\\d+)", "jdk$1");
            if (!altHome.equals(path)){
              jreSrc = new Path(altHome).append("src.zip");
            }

            // second scenerio
            if (!jreSrc.toFile().exists()){
              String base = FileUtils.getBaseName(path);
              final String major = base.replaceFirst("^jre(\\d)$", "$1");
              if (!major.equals(base)){
                File dir = new File(FileUtils.getFullPath(path));
                String[] jdks = dir.list(new FilenameFilter(){
                  private final Pattern JDK =
                    Pattern.compile("jdk\\d+\\." + major + "\\.\\d+_\\d+");
                  public boolean accept(File dir, String name){
                    return JDK.matcher(name).matches();
                  }
                });
                for (String jdk : jdks){
                  jreSrc = new Path(dir.toString()).append(jdk).append("src.zip");
                  if (jreSrc.toFile().exists()){
                    break;
                  }
                }
              }
            }
          }

          // jre src found.
          if(jreSrc.toFile().exists()){
            logger.info("Setting '{}' to '{}'",
                JavaRuntime.JRESRC_VARIABLE, jreSrc);
            newLocations[ii] = new LibraryLocation(
                locations[ii].getSystemLibraryPath(),
                jreSrc,
                locations[ii].getPackageRootPath(),
                locations[ii].getJavadocLocation());

          // jre src not found.
          }else{
            logger.debug(
                "Unable to locate jre src.zip for JAVA_HOME: " +
                SystemUtils.JAVA_HOME);
            newLocations[ii] = new LibraryLocation(
                locations[ii].getSystemLibraryPath(),
                Path.EMPTY,
                locations[ii].getPackageRootPath(),
                locations[ii].getJavadocLocation());
          }
        }else{
          newLocations[ii] = locations[ii];
        }
      }
      vm.setLibraryLocations(newLocations);
    }catch(Exception e){
      logger.error("", e);
    }
  }
View Full Code Here

 

  @Override
  public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {

    IVMInstall vm = verifyVMInstall(config);
    IVMRunner runner = vm.getVMRunner(mode);
    String[] classpath = getClasspath(config);
    VMRunnerConfiguration runConfig = new VMRunnerConfiguration(CucumberFeatureLaunchConstants.CUCUMBER_API_CLI_MAIN, classpath);

    File workingDir = verifyWorkingDirectory(config);
    String workingDirName = null;
View Full Code Here

      entries.addAll(Arrays.asList(javaProject.getRawClasspath()));
    } catch (JavaModelException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    IVMInstall vmInstall= JavaRuntime.getDefaultVMInstall();
    LibraryLocation[] locations= JavaRuntime.getLibraryLocations(vmInstall);
    for (LibraryLocation element : locations) {
    entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
    }
    try {
View Full Code Here

    if ((javaProject == null) || !javaProject.exists()) {
      abort(ResourceUtil.getString("TestNGLaunchConfigurationDelegate.error.invalidproject"), //$NON-NLS-1$
          null, IJavaLaunchConfigurationConstants.ERR_NOT_A_JAVA_PROJECT);
    }

    IVMInstall install = getVMInstall(configuration);
    IVMRunner runner = install.getVMRunner(mode);
    if (runner == null) {
      abort(ResourceUtil.getFormattedString("TestNGLaunchConfigurationDelegate.error.novmrunner", //$NON-NLS-1$
          new String[] { install.getId() }), null,
          IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST);
    }

    int port = SocketUtil.findFreePort();
    VMRunnerConfiguration runConfig = launchTypes(configuration, launch, javaProject, port, mode);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.launching.IVMInstall

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.