More or less as you have shown above, except that you do not try to run the
.java file. You first need to compile your Java source with the
javac command, and then run the class file thus:
javac routing.java
java routing inputfile 2
The input parameters are then accessed from the
args
argument of the
main()
method. The following code demonstrates the basic functionality:
public static void main(String[] args) {
if (args.length > 0) {
System.out.println("Application arguments:");
for (String argName : args) {
System.out.format("\t%s%n", argName);
}
System.out.println("");
}
}