Package laas.openrobots.ontology.helpers
Class JarClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- laas.openrobots.ontology.helpers.JarClassLoader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class JarClassLoader extends java.net.URLClassLoader
A class loader for loading jar files, both local and remote.
-
-
Constructor Summary
Constructors Constructor Description JarClassLoader(java.net.URL url)
Creates a new JarClassLoader for the specified url.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMainClassName()
Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.java.util.jar.Attributes
getManifestEntries()
Returns the entries in the JAR manifestvoid
invokeClass(java.lang.String name, java.lang.String[] args)
Invokes the application in this jar file given the name of the main class and an array of arguments.-
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Method Detail
-
getMainClassName
public java.lang.String getMainClassName() throws java.io.IOException
Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.- Throws:
java.io.IOException
-
getManifestEntries
public java.util.jar.Attributes getManifestEntries() throws java.io.IOException
Returns the entries in the JAR manifest- Throws:
java.io.IOException
-
invokeClass
public void invokeClass(java.lang.String name, java.lang.String[] args) throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
Invokes the application in this jar file given the name of the main class and an array of arguments. The class must define a static method "main" which takes an array of String arguments and is of return type "void".- Parameters:
name
- the name of the main classargs
- the arguments for the application- Throws:
java.lang.ClassNotFoundException
- if the specified class could not be foundjava.lang.NoSuchMethodException
- if the specified class does not contain a "main" methodjava.lang.reflect.InvocationTargetException
- if the application raised an exception
-
-