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:
Closeable
,AutoCloseable
A class loader for loading jar files, both local and remote.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.Returns the entries in the JAR manifestvoid
invokeClass
(String name, 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.security.SecureClassLoader
defineClass, defineClass
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
-
Constructor Details
-
JarClassLoader
Creates a new JarClassLoader for the specified url.- Parameters:
url
- the url of the jar file
-
-
Method Details
-
getMainClassName
Returns the name of the jar file main class, or null if no "Main-Class" manifest attributes was defined.- Throws:
IOException
-
getManifestEntries
Returns the entries in the JAR manifest- Throws:
IOException
-
invokeClass
public void invokeClass(String name, String[] args) throws ClassNotFoundException, NoSuchMethodException, 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:
ClassNotFoundException
- if the specified class could not be foundNoSuchMethodException
- if the specified class does not contain a "main" methodInvocationTargetException
- if the application raised an exception
-