0

Here is my code from the jna sample i am try using native code to run cmd command

boolean status = Kernel32.INSTANCE.CreateProcess(
                    null,
                    "cmd.exe /c echo here is output",
                    null,
                    null,
                    true,
                    new WinDef.DWORD(0),
                    Pointer.NULL,
                    System.getProperty("java.io.tmpdir"),
                    startupInfo,
                    processInformation);

When i run the code i got this in the Compiler

here is output

Is any way to store the Above Output in a string value

Panagiotis Drakatos
  • 2,522
  • 3
  • 26
  • 37

1 Answers1

2

You're going to have a much easier time doing this with Apache Commons Exec with the code from How can I capture the output of a command as a String with Commons Exec?

If you need to specifically use JNA for some reason, you can use what @KompjoeFriek posted -- how to get the process output when using jna and CreateProcessW

Community
  • 1
  • 1
kichik
  • 30,658
  • 6
  • 82
  • 103