1 pièce(s) jointe(s)
warning "static method should be accessed in static way"
Bonjour
Bizuth en Java, j'ai de mal a comprendre comment corriger ce warning.
"The static method hasArg() from the type OptionBuilder should be accessed in a static way"
lors de l'ajout d'un objet option à une collection (lib Apache commons CLI)
Code:
1 2 3 4 5 6
| Option propfile = OptionBuilder.withLongOpt("propfile")
.withDescription("Fichier properties de ce programme")
.withArgName("prop file")
.hasArg()
.create("p");
opts.addOption(propfile); |
Pièce jointe 173606
warning "static method should be accessed in static way"
Je vais donc adopter le méthode qui permet d'ignorer le warning.
Code:
1 2 3 4 5 6 7 8
| // -p toto.txt --propfile=toto.txt
@SuppressWarnings("static-access")
Option propfile = OptionBuilder.withLongOpt("propfile")
.withDescription("Fichier properties de ce programme")
.withArgName("prop file")
.hasArg()
.create("p");
opts.addOption(propfile); |
Question de néophyte, la suppression du warning ne va s'appliquer QUE à la ligne suivant, ou bien à tout ce qui suit ?
Si cette lib est faisandée, quelle lib utiliser pour traiter facilement la ligne de commande ?
B