Bug 25981 - [startup] Error loading plugins launching Main from a directory not from startup.jar
Summary: [startup] Error loading plugins launching Main from a directory not from star...
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Incubator (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: User Unknown CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2002-11-11 11:38 EST by Antonio Edson Ceccon CLA
Modified: 2005-09-27 09:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.