I run java application in command line linux with external jar like this :
java -cp ".:commons-net-3.6.jar" FtpClass
how can I send argument to main class by command line ?
I run java application in command line linux with external jar like this :
java -cp ".:commons-net-3.6.jar" FtpClass
how can I send argument to main class by command line ?
You need to specify arguments after class like this
java -cp ".:commons-net-3.6.jar" FtpClass A B C
Assume example
public class Example {
public static void main (String[] args) {
for (String s: args) {
System.out.println(s);
}
}
}
The following example shows how a user might run Example.
java Example Drink Hot Java
output is
Drink
Hot
Java
if you add this command :
java -cp ".:commons-net-3.6.jar" FtpClass "test1" "test2"
after you can use this main method:
public static void main(String[] args) {
FtpsTest test = new FtpsTest();
test.putFile(args[0],args[1]);
}