qq.log");//*1 when I run qq.exe ...">

Why can't I use log files in java runtime

I have (in java)

rt.exec("qq.exe -i ..(some other parameters) > qq.log");//*1

when I run qq.exe -i .. (some other parameters)> qq.log in the terminal. It works fine and saves the qq.log file correctly.

However, using rt.exec (* 1) does not work. "> qq.log" is causing the problem. When I delete this part, rt.exec (* 1) works, but this time I do not have the qq.log file.

What causes this problem and is there any soln ??

+3
source share
2 answers

rt.exec() sh/bat. . qq.exe >, , java , .

- - exec, Process, rt.exec(). A Process OutputStream , InputStream ErrorStream .

InputStream qq.exe, , , .

+3

Java 7 ProcesBuilder.Redirect, // / . :

    ProcessBuilder builder = new ProcessBuilder("cat", "/proc/meminfo");
    // Append all errors from process to log file:
    builder.redirectError(Redirect.appendTo(new File("/tmp/my.log")));
    Process process = builder.start();

, . : Java 7.

0

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


All Articles