-1

I'm new to both forensics and java. I just learnt java and I find it quite useful. Recently, I am learning how to integrate commands into the java coding. Is this possible?

I am currently using volatility (CLI) software. I am trying to create a GUI version of it. I have started on some basic research on it and I find it really interesting. However, I do not know how to integrate the commands into java.

Thank you. Any help will be greatly appreciated.

Cheers,
Linify

Edit: Here's how the coding is.

try
    {
        Runtime rt = Runtime.getRuntime();

        Process p = rt.exec("cmd.exe /c start cd C:/Users/User/Desktop/DumpIt &");
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

        String line=null;

        while((line=input.readLine()) != null)
        {
            System.out.println(line);
        }

        int exitVal = p.waitFor();
        System.out.println("Exited with error code " +exitVal);

    }
    catch (Exception e)
    {
        System.out.println(e.toString());
        e.printStackTrace();
    }
Linify
  • 227
  • 4
  • 13

1 Answers1

0

You can spawn external processes in Java using the System class (http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html). For example:

String command = "cmd /c start volatility.bat";
Process process = Runtime.getRuntime().exec(command);

With the Process object you can access the input / output / error stream of the external command (see http://docs.oracle.com/javase/7/docs/api/java/lang/Process.html).

mxb
  • 3,300
  • 4
  • 20
  • 25
  • how do I add commands after having it to run change dir? I tried this: – Linify Jul 07 '14 at 21:36
  • Create a batch file to run your whole chain of commands and launch the bat from Java – mxb Jul 08 '14 at 07:19
  • [link](http://stackoverflow.com/questions/24752040/alternatives-to-batch-file-since-i-am-unable-to-include-java-code-in-it) <-- maybe you can help me with this question too. – Linify Jul 16 '14 at 03:56