ideaz ideaz - 1 year ago 237
Java Question

Java XX command line options unrecognized (e.g: -XX:+UseStringDeduplication, -XX:MaxGCPauseMillis)

I am trying to specify some GC tuning options on the command line and for some reason keep running into the 'Unrecognized option' error.

java -Dproperty1=value -Dproperty2=value2 -cp ./some/jarFile1.jar:./some/jarFile2.jar -c /path/to/a/file –XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=200


Exception in thread "main" org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -XX:+UseStringDeduplication

Same thing with the
option if I removed StringDeduplication.

Running Java 8, version info:

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Any clues appreciated.

Answer Source

Be careful when entering characters. The dash before your –XX:+UseG1GC is not the ASCII hyphen/minus, but the “En Dash” character.

If you look closely in the browser view of your question, you might notice a difference in length and vertical position, e.g. when comparing with the -XX:+UseStringDeduplication option. However, that depends on the actual font and it is not unlikely that both characters look the same in the editor/console where you entered the command line.

For java command line options, you have to always use the ASCII hyphen/minus character (U+002D) which should be the default when pressing - on an ordinary keyboard.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download