As mentioned in the other questions, you get that warning if starting any java
process when the JAVA_TOOL_OPTIONS
environment variable is declared. This is mentioned in Windows Android Studio logs on start-up, and also if you run java -version
from a terminal / cmd.exe.
Before removing first check whether you need these addition settings or not. The setting -Dfile.encoding=UTF8
is default for JDK19 onwards, but not for earlier JDKs and fixing to avoid an Android Studio warning might cause unexpected changes elsewhere with other Java based applications on pre-JDK19.
Two places I know where it could be defined:
Settings > System > About > Advanced System Settings -> Environment Variables:
Delete JAVA_TOOL_OPTIONS
values under your user settings or System settings.
This setting can be added back by re-entering in the dialog or typing command: setx JAVA_TOOL_OPTIONS blah
.
Don't forget to close/re-open Windows Terminal or CMD.EXE after making changes to the environment variables or they won't see the new values.
As a local variable in CMD.EXE. This setting may have been added by some init script (say if you use CMD.EXE /k init.cmd
) calling set JAVA_TOOL_OPTIONS=blah
and this overrides / replaces 1) value.
You may be able to remove with set JAVA_TOOL_OPTIONS=
and re-running java or Android Studio from that CMD, but note that the original value will be restored after close/re-open CMD if it was set in 1) already.
There is no doubt an easier way to do this as annoyingly it adds a blank cmd terminal: if you wished to disable for just Android Studio you could set up an alternative windows shortcut with this as "Target" field (do no add any extra spaces):
cmd.exe /c set JAVA_TOOL_OPTIONS=&&"C:\Program Files\Android\Android Studio\bin\studio64.exe"
Note:
setx VARNAME NEWVALUE
does not need "=" sign.
set VARNAME=NEWVALUE
requires the "=" sign