How can I use a batch file to work as a Java console that accepts input? I made a test application with a couple commands, and I run the jar file using this line in a batch file:
java -cp console.jar test.Main
When I attempt to type something in the batch window, it closes. What would be the correct approach?
Here is my main method. I use a Scanner to get the user input.
public static void main(String[] args) {
scanner = new Scanner(System.in);
String line = scanner.nextLine();
if (line.startsWith("--")) {
String[] command = line.split("--");
new Command(command[1]);
}
}
Thanks in advance.
Commandinstance and then does nothing. So the program terminates. What else did you expect?