Hi all,
I would like to execute an OS command like "cls" from my Java program, and am getting the following error:
D:\ext>java FileExtractionConsole
Exception in thread "main" java.lang.NullPointerException
at FileExtractionConsole.startExtraction(FileExtractionConsole.java:46)
at FileExtractionConsole.main(FileExtractionConsole.java:33)
D:\ext>
Here's the snipt of my code:
public class FileExtractionConsole {
public static void main (String [] arg){
FileExtractionConsole fe = new FileExtractionConsole ();
fe.displayMainMenu();
}
private void displayMainMenu () {
try {
Process p = Runtime.getRuntime().exec("cls"); // exception occurs here.
System.out.println("\n FILE EXTRACTION UTILITY\n\n");
System.out.println(" Please enter User ID and Password");
BufferedReader stdin = new BufferedReader( ....
// rest of the code...
} catch (IOException io) {
printStream.println("Exception occured: " + io.getMessage());
}
}
}
I get an exception on the line where I try to execute "cls" command. Am I doing something not correct here? Please advise...
Thanks.