3

When I turned Android Studio on Windows 10, I got this warning:

The use of Java options environment variables detected. Such variables override IDE configuration files (*.vmoptions) and may cause performance and stability issues. Please consider deleting these variables: JAVA_TOOL_OPTIONS.

So, I want to delete this variable, but I don't know how. This similar query didn't help me because I don't see this variable in system variables. I suspect I must have set it via the command line when I was troubleshooting another issue. When starting the console of any IDE, the message:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

Is also displayed. Can it be deleted somehow?

Adam
  • 186
  • 1
  • 4
  • 20
  • Did you check the user environment variables, too? – Slaw Sep 24 '22 at 08:08
  • Yes, but there is nothing with Java at all. – Adam Sep 24 '22 at 08:11
  • Is it not possible to delete it programmatically via the command line? – Adam Sep 24 '22 at 08:12
  • In CMD, what does `echo %java_tool_options%` output? (Or in PowerShell, what does `$env:java_tool_options` output?) – Slaw Sep 24 '22 at 08:13
  • This will print `%java_tool_options%` – Adam Sep 24 '22 at 08:18
  • Then as far as I know, that means the `java_tool_options` environment variable doesn't exist in your system or user variables. Perhaps the variable is being set only for the Android Studio process--in which case I don't know how to fix that. – Slaw Sep 24 '22 at 08:21
  • Ok, thanks for trying to help me. That would probably explain why I don't see it there, but as I said, I was setting the variable via the command line and not in Android Studio. – Adam Sep 24 '22 at 08:25
  • 1
    I'll be honest, I don't know all the nuances of environment variables in Windows. But I'm pretty sure setting an environment variable in a terminal only sets it locally (i.e., for that terminal session; processes started in that session will probably see the variable), and only temporarily (i.e., if you open another terminal the variable will no longer be set). If you had set the environment variable permanently, then I believe you would see it in the GUI. – Slaw Sep 24 '22 at 08:28
  • This sounds like an OS specific question, but you did not say what your OS is. – Stewart Oct 12 '22 at 13:25
  • Sorry, my operating system is Windows 10. – Adam Oct 12 '22 at 13:30
  • Maybe add Window Tag? – Brentspine Oct 12 '22 at 13:31
  • what does `set` output in cmd? – Brentspine Oct 12 '22 at 14:46
  • Lists a bunch of variables, including this one: `JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8` – Adam Oct 12 '22 at 14:54

1 Answers1

2

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:

  1. 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.

  2. 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
DuncG
  • 12,137
  • 2
  • 21
  • 33