简体   繁体   English

检测到使用 Java 选项环境变量。 如何删除它?

[英]The use of Java options environment variables detected. How to delete it?

When I turned Android Studio on Windows 10, I got this warning:当我在 Windows 10 上打开 Android Studio 时,我收到了这个警告:

The use of Java options environment variables detected.检测到使用 Java 选项环境变量。 Such variables override IDE configuration files (*.vmoptions) and may cause performance and stability issues.此类变量会覆盖 IDE 配置文件 (*.vmoptions),并可能导致性能和稳定性问题。 Please consider deleting these variables: JAVA_TOOL_OPTIONS.请考虑删除这些变量: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:启动任何 IDE 的控制台时,消息:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8拿起 JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

Is also displayed.也显示出来。 Can it be deleted somehow?它可以以某种方式删除吗?

As mentioned in the other questions, you get that warning if starting any java process when the JAVA_TOOL_OPTIONS environment variable is declared.正如其他问题中提到的,如果在声明JAVA_TOOL_OPTIONS环境变量时启动任何java进程,您会收到该警告。 This is mentioned in Windows Android Studio logs on start-up, and also if you run java -version from a terminal / cmd.exe.这在启动时的 Windows Android Studio 日志中提到过,如果您从终端/cmd.exe 运行java -version也提到过。

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.设置-Dfile.encoding=UTF8是 JDK19 及更高版本的默认设置,但不是早期 JDK 的默认设置,并且为避免 Android Studio 警告而进行的修复可能会导致 JDK19 之前的其他基于 Java 的应用程序在其他地方发生意外更改。

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.删除用户设置或系统设置下的JAVA_TOOL_OPTIONS值。

    This setting can be added back by re-entering in the dialog or typing command: setx JAVA_TOOL_OPTIONS blah .可以通过在对话框中重新输入或键入命令来添加回此设置: 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.不要忘记在更改环境变量后关闭/重新打开 Windows 终端或 CMD.EXE,否则它们将看不到新值。

  2. As a local variable in CMD.EXE.作为 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.此设置可能已由某些初始化脚本添加(例如,如果您使用CMD.EXE /k init.cmd )调用set JAVA_TOOL_OPTIONS=blah并且这会覆盖/替换 1) 值。

    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.您可以使用set JAVA_TOOL_OPTIONS=删除并从该 CMD 重新运行 java 或 Android Studio,但请注意,如果已在 1) 中设置,则在关闭/重新打开 CMD 后将恢复原始值。

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 终端,这很烦人:如果你只想禁用 Android Studio,你可以设置一个替代的 Windows 快捷方式,并将其作为“目标”字段(不要添加任何额外的空格) ):

cmd.exe /c set JAVA_TOOL_OPTIONS=&&"C:\Program Files\Android\Android Studio\bin\studio64.exe"

Note:笔记:

  • setx VARNAME NEWVALUE does not need "=" sign. setx VARNAME NEWVALUE不需要“=”号。
  • set VARNAME=NEWVALUE requires the "=" sign set VARNAME=NEWVALUE需要“=”符号

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java中使用Jenkins中的环境变量? - How to use environment variables in Jenkins by the Java? 如何使用 Java 在 CMD 中使用环境变量? - How to use environment variables in CMD using Java? java.sql.SQLException:检测到未定义的列名。 (休眠) - java.sql.SQLException: An undefined column name was detected. (Hibernate) Java和Eclipse如何使用环境变量? (MAC OS X) - How to use environment variables in Java with Eclipse? (MAC OS X) 如何使用Java类中Cloudhub上设置的环境变量 - How to use Environment variables setted on cloudhub in java class 如何为Java设置环境变量 - How to set environment variables for Java JAVA_TOOL_OPTIONS 中的环境变量没有得到扩展 - Environment variables are not getting expanded in JAVA_TOOL_OPTIONS 滚动滚动获取RecyclerView异常:-“ java.lang.IndexOutOfBoundsException:检测到不一致。 无效的商品位置21” - On scroll the RecyclerView getting exception : -“ java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 21” 部署到AppFog时未检测到环境变量 - Environment variables not detected when deploying to AppFog 从单独的线程更新 Realm 时,如何避免“检测到不一致。项目位置无效”? - How can I avoid "Inconsistency detected. Invalid item position" when updating Realm from separate thread?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM