-1

Hi i want to create a java program that i can run in two languages putting a option (eg. "--language=english") in the run command like this:

java --language="english" ClassName.java
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724

1 Answers1

0

If you put in the --languages argument after the ClassName.java it gets picked up as a argument and you will have it in the args array of the main method. Then you just have to parse it and you're done.

SIMULATAN
  • 833
  • 2
  • 17
  • 1
    Thank you very much for answering me. I know of args array, but i need to know if i can create a true custom command line option. Thanks again. – Mario Barbieri Oct 18 '21 at 13:23
  • you will have to add custom command parsing: https://stackoverflow.com/questions/367706/how-do-i-parse-command-line-arguments-in-java – SIMULATAN Oct 18 '21 at 14:57