I am new to java development in Netbeans and I am having a problem entering input parameters in Netbeans. If I create a project and start the jar using cmd, everything works fine, but I donโt know how to provide parameters in the IDE.
Here is an example for testing:
public class NetbeansRunParams {
public static void main(String[] args) {
if (args.length != 3) {
System.out.println("Missing input arguments!");
System.out.println("Run example: java -jar test.jar agrument1 argument2 argument3");
System.exit(0);
}
System.out.println(String.format("First argument has value: %s", args[0]));
System.out.println(String.format("Second argument has value: %s", args[1]));
System.out.println(String.format("Third argument has value: %s", args[2]));
}
}
So, every time I run this code using Netbeans, I get the following output in the console:
run:
Missing input arguments!
Run example: java -jar test.jar agrument1 argument2 argument3
BUILD SUCCESSFUL (total time: 0 seconds)
source
share