add test code for running jar with arguments

This commit is contained in:
Liesheng Long 2019-04-19 19:08:52 -04:00
parent 1a01445b6f
commit 5eb2a6e04e
2 changed files with 28 additions and 1 deletions

View File

@ -3,7 +3,16 @@ package com.baeldung.jar;
public class JarExample { public class JarExample {
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("Hello Baeldung Reader!"); System.out.println("Hello Baeldung Reader in JarExample!");
if(args == null) {
System.out.println("You have not provided any arguments!");
}else {
System.out.println("There are "+args.length+" argument(s)!");
for(int i=0; i<args.length; i++) {
System.out.println("Argument("+(i+1)+"):" + args[i]);
}
}
} }
} }

View File

@ -0,0 +1,18 @@
package com.baeldung.jar;
public class JarExample2 {
public static void main(String[] args) {
System.out.println("Hello Baeldung Reader in JarExample2!");
if(args == null) {
System.out.println("You have not provided any arguments!");
}else {
System.out.println("There are "+args.length+" argument(s)!");
for(int i=0; i<args.length; i++) {
System.out.println("Argument("+(i+1)+"):" + args[i]);
}
}
}
}