1. Using NetBeans, code the following Java application, and run it on Command prompt (Terminal If Linux) with the argument "notepad" (or "gedit" if Linux).
import java.io.*;
public class DSProcess
{
public static void main(String[] args) throw IOException
{ if (args.length! = 1) {
System.err.println('Usage: Java OSProcess "), System.exit(0):
}
// args(0) is the command that is run in a separate process
ProcessBuilder pb = new ProcessBuilder(args[0]);
Process process - pb.start();
// obtain the input stream
InputStream is - process.getInputStrean();
ImputStreamReader isr = new InputStreanReader(is);
Bufferedheader br = new BufferedReader(isr);
// reed the output of the process String line;
while ( (line = br.readLine()) != null)
Systen.out.prIntln(line);
br.close();
}
}
Provide screen shots for,
- NetBeans code screen
- command prompt or terminal screen when you run the application.
You should run the application with the command;
Java -jar OSProcess. jar notepad
or
java -jar OSProcesa . jar gedit
2. Run the command puree on your Ubuntu virtual machine you have installed in Assignment 1. you should run the command on a terminal screen in Ubuntu. Provide screen shot of the full tree.