Help run jar from java program with JarClassLoader

I am trying to run a jar in a java program and grab its stdout. I want to do this to avoid loading the JVM every time the jar starts. . What is the easiest way to do this?

I started by modifying the Java JarClassLoader and adding a SecurityManager subclass to it to prevent logging out. JarClassLoader is a subclass of URLClassLoader and it scans the main class in the bank, and then performs the main function. But now I get InvocationTargetExceptions when I try to execute this function, even if I pass the correct arguments. Anyone with an idea where to go from here?

Is there an easier way to do this?

+3
source share
1 answer

I would just use it Runtime.exec(), but then I could not prevent it System.exit().

0
source

Source: https://habr.com/ru/post/1723942/


All Articles