Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {

    public static void main(String[] args) {
        try {
            String[] cmdArray = new String[2];
            // first argument is the program to open
            cmdArray[0] = "notepad.exe";

            // data.txt is the file to open with notepad
            cmdArray[1] = "data.txt";

            // create a process and execute cmdArray

            Runtime runTime = Runtime.getRuntime();

            Process process = runTime.exec(cmdArray);

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}