1

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 ?

Saeed Aliakbari
  • 281
  • 4
  • 20

2 Answers2

2

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
fxrbfg
  • 1,756
  • 1
  • 11
  • 17
1

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]);
        }
jack.ali
  • 11
  • 2