Fill Array args parameters without leaving Eclipse

3

I have parameters that are passed when executing the .jar of my code, in args , as in this example:

public static void main(String[] args) {
        final File diretorio = new File(args[0]);
        final String extencao = "." + args[1];
        final String origem = "\"+args[2];
        final String destino = "\"+args[3];

I want to know if it is possible for me to define the values I am passing in the command line through Eclipse, without having to change the values of the variables or call separately by the console.

    
asked by anonymous 28.11.2018 / 23:51

1 answer

6

As removed from this answer , the instructions below is in case you have already run your class that owns the method main at least once within the IDE:

  • On the menu, click Run , then Run Configurations... . A screen similar to this will appear:

  • Inthedrop-downlistontheside,lookforthenameofyourclassthatwantstopassparametersonmain,inmycase,itistheclassthatisalreadyselected,MainParametrosTest.
  • clicktheArgumentstabanditwillappearasprintbelow:

IntheProgramArgumentsfield,youwillentertheargumentsyouwanttopasstothemainofyourclassseparatedbyaspace.

Seetheexamplebelow,whereIpassedargumento1argumento2argumento3:

    
29.11.2018 / 00:03