java - How to execute a jar file within a jar file -
I have a project that the structure can not be changed. What do I do?
I have a main jar file that contains the director
/ classes / lib / main / manifest
I have to call a test 1 class when I execute the main jar file. So in the manifest file I gave the path of the main-class: path.to.file.
I have another jar file inside the main
folder that contains the actual application. To execute the jar in the main folder, and your Test2 mentioned in the manifest file
What can I do to execute the class.
Please appreciate me any help to solve or work in any direction.
You can not do this in the existing class loader, you need a new one.
If the name of your jar is foobar.jar
and you have main
-method class test.abc.main
The URL can be used to:
url [] url = {new URL ("Classloader: / maine / fieobar.jager"}} classloader parent class loader = it.get class () GetClassLoader (); URL Class Loader Child Class Loader = New URL Class Loader (URL, Parent Class Loader); Class Claz = Child Classloader. Load Class ("test.abc.Main"); String [] Logic = New String [] {}; Clazz.getMethod ( "main", arguments.getClass ()). Invoke (empty argument);
Comments
Post a Comment