Populate Array args parameters without exiting Eclipse

Asked

Viewed 441 times

4

I have parameters that are passed when running 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 set the values I am passing on the command line by Eclipse, without having to change the values of the variables or call separately from the console.

1 answer

7


As withdrawn of this answer, the instructions below are in case you have already run your class that has the main method at least 1 time within the IDE:

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

inserir a descrição da imagem aqui


  • in the drop-down list on the side, look for the name of your class that wants to pass parameters in main, in my case, it is the class that is already selected, MainParametrosTest.

  • click on the tab Arguments and will appear as the print below:

inserir a descrição da imagem aqui

On the field Program Arguments, you will insert the arguments you want to pass to the main of your class separated by a space.

See the example below, where I passed argumento1 argumento2 argumento3:

inserir a descrição da imagem aqui

  • Thank you very much, it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.