net.aavalla.utils.general
Class DynamicClassLoader

java.lang.Object
  extended by net.aavalla.utils.general.DynamicClassLoader

public class DynamicClassLoader
extends java.lang.Object

Author:
Lari Natri

Constructor Summary
DynamicClassLoader()
           
 
Method Summary
static void addFile(java.io.File f)
          Add file to CLASSPATH
static void addFile(java.lang.String s)
          Add file to CLASSPATH
static void addURL(java.net.URL u)
          Add URL to CLASSPATH
static boolean loadJar(java.io.File[] paths, java.lang.String jarFileName, java.lang.String testClassName)
          Tries to add a .jar file to classpath.
static boolean loadNativeLibrary(java.lang.String libName, java.io.File[] paths)
          Tries to load a native system library.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicClassLoader

public DynamicClassLoader()
Method Detail

addFile

public static void addFile(java.lang.String s)
                    throws java.io.IOException
Add file to CLASSPATH

Parameters:
s - File name
Throws:
java.io.IOException - IOException

addFile

public static void addFile(java.io.File f)
                    throws java.io.IOException
Add file to CLASSPATH

Parameters:
f - File object
Throws:
java.io.IOException - IOException

addURL

public static void addURL(java.net.URL u)
                   throws java.io.IOException
Add URL to CLASSPATH

Parameters:
u - URL
Throws:
java.io.IOException - IOException

loadJar

public static boolean loadJar(java.io.File[] paths,
                              java.lang.String jarFileName,
                              java.lang.String testClassName)
Tries to add a .jar file to classpath.

Parameters:
paths - paths to search for the jar
jarFileName - filename without path but with .jar
testClassName - Binary name of a class that should be within the wanted jar file. If such a class is not found, the jar is not added to the classpath. Example: compid.utils.DynamicClassLoader
Returns:
true if jar was found and added, false otherwise

loadNativeLibrary

public static boolean loadNativeLibrary(java.lang.String libName,
                                        java.io.File[] paths)
Tries to load a native system library. Given paths are tried first and if they fail, normal system call is used.

Parameters:
libName - Library name
paths - paths to check.
Returns:
True, if loading was succesful, false otherwise.