I want to run a program using the following commands
java Main -host arg1 arg2
However I have faced some troble as I had made the project in separate packages. So I get a jar file and cannot run the main from the above keywords. I have to call the jar file thus from the command line.
java -jar Main.jar arg1 arg2
However I do not want that as it goes against my specification.
Can you help me please?
SPECIFICATION
A text-only application is all that is required. It must be networked and run as either a host (server) or a client from the command line using the commands:
java BankApp -host PORT
java BankApp -client MACHINE PORT
to start as host or client respectively. For example, if you know the host is running on aloha at port 8888 you would connect with:
java BankApp -client aloha 8888
what I need to do to run is as follows.
java -jar C:\Users\UniversityofBristol\Desktop\BankApp\BankApp\dist BankApp.jar arg1 arg2
public class BankApp {
public static void main(String[] args) throws IOException, ClassNotFoundException {
String current = new java.io.File(".").getCanonicalPath();
current = "java -jar " + current + "\\dist";
current = "\"" + current + "\"";
current = current + " BankApp.jar";
System.out.println("Current dir:" + current);
// Run a java app in a separate system process
Process proc = Runtime.getRuntime().exec(current);
// Then retreive the process output
InputStream in = proc.getInputStream();
InputStream err = proc.getErrorStream();
}
}