public static void main( String [] args ) throws Exception { URL [] urls = new URL [ args.length ]; for(int i=0; i< args.length; i++) urls[i] = new File(args[i]).toURL(); BshClassPath bcp = new BshClassPath( "Test", urls ); }
/** A BshClassPath initialized to the user path from java.class.path */ public static BshClassPath getUserClassPath() throws ClassPathException { if ( userClassPath == null ) userClassPath = new BshClassPath( "User Class Path", getUserClassPathComponents() ); return userClassPath; }
/** A BshClassPath initialized to the user path from java.class.path */ public static BshClassPath getUserClassPath() throws ClassPathException { if ( userClassPath == null ) userClassPath = new BshClassPath( "User Class Path", getUserClassPathComponents() ); return userClassPath; }
/** Clear all classloading behavior and class caches and reset to initial state. */ @Override public void reset() { baseClassPath = new BshClassPath("baseClassPath"); baseLoader = null; loaderMap = new HashMap(); classLoaderChanged(); // calls clearCaches() for us. }
/** Clear all classloading behavior and class caches and reset to initial state. */ @Override public void reset() { baseClassPath = new BshClassPath("baseClassPath"); baseLoader = null; loaderMap = new HashMap(); classLoaderChanged(); // calls clearCaches() for us. }
/** Get the boot path including the lib/rt.jar if possible. */ public static BshClassPath getBootClassPath() throws ClassPathException { if ( bootClassPath == null ) { try { //String rtjar = System.getProperty("java.home")+"/lib/rt.jar"; String rtjar = getRTJarPath(); URL url = new File( rtjar ).toURL(); bootClassPath = new BshClassPath( "Boot Class Path", new URL[] { url } ); } catch ( MalformedURLException e ) { throw new ClassPathException(" can't find boot jar: "+e); } } return bootClassPath; }
/** Get the boot path including the lib/rt.jar if possible. */ public static BshClassPath getBootClassPath() throws ClassPathException { if ( bootClassPath == null ) { try { bootClassPath = new BshClassPath( "Boot Class Path", new URL[] { getRTJarPath() } ); } catch ( MalformedURLException e ) { throw new ClassPathException(" can't find boot jar: "+e, e); } } return bootClassPath; }
/** Get the full blown classpath. */ public BshClassPath getClassPath() throws ClassPathException { if ( fullClassPath != null ) return fullClassPath; fullClassPath = new BshClassPath("BeanShell Full Class Path"); fullClassPath.addComponent( BshClassPath.getUserClassPath() ); try { fullClassPath.addComponent( BshClassPath.getBootClassPath() ); } catch ( ClassPathException e ) { System.err.println("Warning: can't get boot class path"); } fullClassPath.addComponent( baseClassPath ); return fullClassPath; }
/** Get the full blown classpath. */ public BshClassPath getClassPath() throws ClassPathException { if ( fullClassPath != null ) return fullClassPath; fullClassPath = new BshClassPath("BeanShell Full Class Path"); fullClassPath.addComponent( BshClassPath.getUserClassPath() ); try { fullClassPath.addComponent( BshClassPath.getBootClassPath() ); } catch ( ClassPathException e ) { System.err.println("Warning: can't get boot class path"); } fullClassPath.addComponent( baseClassPath ); return fullClassPath; }
/** Overlay the entire path with a new class loader. Set the base path to the user path + base path. No point in including the boot class path (can't reload thos). */ @Override public void reloadAllClasses() throws ClassPathException { BshClassPath bcp = new BshClassPath("temp"); bcp.addComponent( baseClassPath ); bcp.addComponent( BshClassPath.getUserClassPath() ); setClassPath( bcp.getPathComponents() ); }
/** Overlay the entire path with a new class loader. Set the base path to the user path + base path. No point in including the boot class path (can't reload thos). */ @Override public void reloadAllClasses() throws ClassPathException { BshClassPath bcp = new BshClassPath("temp"); bcp.addComponent( baseClassPath ); bcp.addComponent( BshClassPath.getUserClassPath() ); setClassPath( bcp.getPathComponents() ); }