Bug 25981

Summary: [startup] Error loading plugins launching Main from a directory not from startup.jar
Product: [Eclipse Project] Equinox Reporter: Antonio Edson Ceccon <antonio.ceccon>
Component: IncubatorAssignee: User Unknown <unknown1>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 Keywords: investigate
Version: unspecified   
Target Milestone: 3.0 M9   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Antonio Edson Ceccon CLA 2002-11-11 11:38:16 EST
If you try to run eclipse loading org.eclipse.core.launcher.Main from 
a directory not from startup.jar the method getRootURL return a directory
without a trailler slash '/'.  That way plugins couldn´t be loaded because
detectplugins method don´t append a slash before "plugins" directory.

So, I put a correction in the getRootURL see below :
*******************************************************************
Main.java file
*******************************************************************

package org.eclipse.core.launcher;

public class Main {
    .
    .
    .
    
   /**
    * Returns url of the location this class was loaded from
    */
   private URL getRootURL() throws MalformedURLException
   {
      if (rootLocation != null)
          return new URL(rootLocation);
		
      URL url = getClass().getProtectionDomain().getCodeSource().getLocation();

      String path = decode(url.getFile());

      path = new File(path).getAbsolutePath().replace(File.separatorChar,'/');

      if ( path.endsWith(".jar")) //$NON-NLS-1$
           path = path.substring(0, path.lastIndexOf("/")+1); //$NON-NLS-1$

      //////////////////////////////////////////////////////////////////
      //                 NEW CODE BLOCK                               //
      //  Append a separator if you load this class from a directory  //
      //  not from startup.jar file.                                  //
      //////////////////////////////////////////////////////////////////
      
      if( !path.endsWith("/") )
      {
         path += '/';    	
      }
      
      ////////////////////////////////////////////////////////////

      url = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);

      //  It seems that you don´t need this line.
      //  rootLocation = url.toExternalForm();

      return url;
   }
}
Comment 1 DJ Houghton CLA 2004-04-29 10:26:41 EDT
Moving to Equinox for comment. This code has changed drastically in the past few
months.
Comment 2 Jeff McAffer CLA 2004-04-29 22:44:33 EDT
we run with startup in a dir all the time now.  closing as fixed.