tags:

views:

144

answers:

2

I have a list of jars that contains jar with needed main-class. I try to run it main class:

public static void runCommandlineMain(String classPathFile, String args[]) throws Exception{
    URL[] urls = getJarUrls(classPathFile);
    URLClassLoader classLoader = new URLClassLoader(urls);

    Class<?> clazz = classLoader.loadClass("liquibase.commandline.Main");
    Method main = clazz.getMethod("main", String[].class);
    main.invoke(null, new Object[]{args});
}

But after run I've follow:

Process finished with exit code -1

and nothing more. How can i resolve it? And how to get console out put from this class?

A: 

Didn't quite get your first question.

But, to answer your second question: "How do you get console output"

try the StreamGobbler here

Ryan Fernandes
A: 

I'm not sure about what the question is about too, but according to the posted snipped, the process which should have the output captured just runs in a different thread. In this scenario you should be able to just redirect the Sytem.out (or System.err respectively) stream.

Call

System.setOut(new PrintStream(your-output-stream));
System.setErr(new PrintStream(your-output-stream));

before invoking the Main class and its output should get redirected to your custom OutputStream.

HerdplattenToni