Having a computer with the system property user.language set to de
, I would like to see the compiler messages in English.
In this post two methods are proposed for java8:
to use the -Duser.language=en
switch on the command line, but -D
isn't shown in the list of available switches for javac 20 any more.
to set an environment variable by the name JAVA_TOOL_OPTIONS under Windows. This, however, sets both java and javac to the desired language, but I would like only the compiler language to be changed.
The above mentioned post also tells trying -J-Duser.language=en
which is rejected at my site with Fehler: Ungültiges Kennzeichen: .language=en
which might read in English "Error: Invalid token/indicator: .language=en"
I accepted DuncG's answer, but the actual solution is in his comment to the original question. Thank you.
On my JDK installation the -J
flag can be used, though this does not work for all language codes:
C:\dev>javac -J-Duser.language=de ayx.java
Fehler: Datei nicht gefunden: ayx.java
Verwendung: javac <Optionen> <Quelldateien>
Mit --help können Sie eine Liste der möglichen Optionen aufrufen
C:\dev>javac -J-Duser.language=en ayx.java
error: file not found: ayx.java
Usage: javac <options> <source files>
use --help for a list of possible options
EDIT
The above works on Linux or Windows CMD, but Windows Powershell reports an error as appears to process the single parameter -J-Duser.language=de
as two parameters -J-Duser
then .language=de
. For Powershell just add quotes to handle as single parameter value:
PS C:\dev> javac -J-Duser.language=de xyz.java
error: invalid flag: .language=de
Usage: javac <options> <source files>
use --help for a list of possible options
PS C:\dev> javac "-J-Duser.language=de" xyz.java
Fehler: Datei nicht gefunden: xyz.java
Verwendung: javac <Optionen> <Quelldateien>
Mit --help können Sie eine Liste der möglichen Optionen aufrufen