zsocc zsocc - 1 year ago 89
Java Question

Java command line set argument with "="

I have a method:

public String sample (String A, int B, int C){
String fin = "";
return fin;

I want to run it in command line like this:
d:>java -jar prac.jar B=5

How can I set parameter in command line with "="?

Answer Source

In your main method, you deal with parameters that are passed:

public static void main(String[] args) {
    // args[0] = parameter 1;
    // args[1] = parameter 2;
    // args[n] = parameter n+1;
    sample(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2])); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download