Java: Make runnable java-file
Hey there,
I've got a java app sofar, which works great via commandline. If there are no arguments passed, it runs in interactive mode which means that I'm printing text wiht System.out.println() and reading users input via:
Code:
public String readString()
{
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
String str = "";
try {
str = reader.readLine();
}
catch (IOException e) {}
return str;
}
The program must be rund from commandline with:
java -jar program.jar
1. I'm wondering how to do that the program gets interpreted directly by simply typing program.jar? Is there a way to or do I always need the "java -jar" in front?
The second way of using it is something with arguments like
java -jar program.jar -bla -foo
Then there might (depending on the arguments) an output via System.out.println() or not.
2. My second question is how to extend the functionality to have a GUI with some checkboxes and one or two (the second input-box is only needed when activating another checkbox) textfields when opening the program by double-clicking it? The functionality (inteactive mode in command line or mode to use command line arguments) should not be changed and should be preserved, so that there's a third way of using the program!
Thanks so far!