Java wrapper around PE (.exe)

Is there a way to make a Java program (on Windows) that just acts like a wrapper around PE (.exe), passing all the stdin input to the program and writing to output all the files that the PE issues.

I need this because the interface for the program only allows Java classes, but I want it to run some code that I compiled in C ++.

Thanks in advance.

edit: portability is important 0%. This is only needed to work on Windows and will never be needed to work anywhere else.

+3
source share
3 answers

Take a look at ProcessBuilder :

 ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
 Map<String, String> env = pb.environment();
 env.put("VAR1", "myValue");
 env.remove("OTHERVAR");
 env.put("VAR2", env.get("VAR1") + "suffix");
 pb.directory("myDir");
 Process p = pb.start();

and another example of this .

+5

, java.lang.Runtime.ecec() java.lang.Process, 3 (in/out/err) *.exe, .

+2

Java (ProcessBuilder ). stdout/stdin/errout (). - Java-, (, C system) JNI JNA ().

+1

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


All Articles