0

For every program/utility on Unix, I would type the name of the program followed by --version to check its version, like so

program --version

If I understand correctly, the double dash -- is used to specify a single option named version instead of -version, which would mean 7 options v,e,r,s,i,o,n. Why is it then that for java and javac I have to use -version with a single dash. Java --version does not even work. Can someone please explain this to me? Thank you in advance.

1 Answers1

1

The underlying issue is that every application implements its own argument parsing. From there it follows that each person/organisation might standardise on a format, but you can't convince everyone to follow a single standard.

There are several pieces of historical baggage which make the situation worse:

  • The BSD tools and POSIX generally only support the compact -v format.
  • GNU tools have expanded on POSIX to also support the human-readable --version format. They can't support -version since it's ambiguous.
  • Microsoft standardised on slash as the leading character instead of a hyphen. Since they developed all the core tools for Windows they basically dictated the argument parsing there, which means it's much more uniform.
  • Some organisations only support human-readable options, so they can use a single hyphen as the prefix to save typing.
l0b0
  • 50,672
  • 41
  • 197
  • 360
  • And Java specifically started out (in the 90s and 00s) using the `-char(s)/--word` convention, but in recent years has added lots of `-word` items and discouraged, if not actually deprecated or removed, the `-char` forms. For example `java` in 9 up (but not 8, which OP may have) has both `-version` and `--version` which produce _slightly_ different output, and `-fullversion` but not `--fullversion`. – dave_thompson_085 Feb 17 '23 at 01:31