调试期间的大写与大写环境变量名称

时间:2016-08-30 15:58:27

标签: java eclipse java-8 environment-variables

在调试与启动会话期间可能导致以下不同行为的原因是什么?

在eclipse-debug和maven-run中,我在eclipse-run中获得大写的所有环境变量,其中一些保留在windows中定义。

@Test
public void testEnvironmentVariables() {
    ArrayList<String> keys = new ArrayList<>(System.getenv().keySet());
    Collections.sort(keys);
    System.out.println(keys);
}

输出如果由运行执行:请注意http.proxyUser

[=::, ALLUSERSPROFILE, APPDATA, APR_ICONV_PATH, CLASSPATH, CLINK_DIR, COMPUTERNAME, ChocolateyBinRoot, ChocolateyInstall, ComSpec, CommonProgramFiles, CommonProgramFiles(x86), CommonProgramW6432, DEBUG_PORT, DEFLOGDIR, EC_COMPUTER_OU, EC_HOMEAPPDATA, EC_USER_DEPARTMENT, EC_USER_DG, EC_USER_DISPLAY_NAME, EC_USER_ELK, EC_USER_OU, EXTRA_JAVA_PROPERTIES, FP_NO_HOST_CHECK, GRADLE_HOME, HOMEDRIVE, HOMEPATH, JAVA_HOME, JAVA_OPTS, LDMS_LOCAL_DIR, LOCALAPPDATA, LOGONSERVER, LocalRunSetup, M2, M2_HOME, M2_REPO, MAVEN_OPTS, MW_HOME, NUMBER_OF_PROCESSORS, ORACLE_BASE, ORACLE_HOME, OS, PATH2, PATHEXT, PROCESSOR_ARCHITECTURE, PROCESSOR_IDENTIFIER, PROCESSOR_LEVEL, PROCESSOR_REVISION, PSModulePath, PUBLIC, Path, ProgramData, ProgramFiles, ProgramFiles(x86), ProgramW6432, SBT_HOME, SESSIONNAME, SFT_SOFTGRIDSERVER, SystemDrive, SystemRoot, TEMP, TMP, USERDNSDOMAIN, USERDOMAIN, USERDOMAIN_ROAMINGPROFILE, USERNAME, USERPROFILE, UUMDS_CFG, VAGRANT_HOME, VBOX_MSI_INSTALL_PATH, VSEDEFLOGDIR, chocolatey_bin_root, debugFlag, http.proxyHost, http.proxyPassword, http.proxyPort, http.proxyUser, http_proxy, https.proxyHost, https.proxyPassword, https.proxyPort, https.proxyUser, https_proxy, myProxy, no_proxy, uumds.config.location, windir, windows_tracing_flags, windows_tracing_logfile]

输出如果由调试执行:请注意HTTP.PROXYUSER

[ALLUSERSPROFILE, APPDATA, APR_ICONV_PATH, CHOCOLATEYBINROOT, CHOCOLATEYINSTALL, CHOCOLATEY_BIN_ROOT, CLASSPATH, CLINK_DIR, COMMONPROGRAMFILES, COMMONPROGRAMFILES(X86), COMMONPROGRAMW6432, COMPUTERNAME, COMSPEC, DEBUGFLAG, DEBUG_PORT, DEFLOGDIR, EC_COMPUTER_OU, EC_HOMEAPPDATA, EC_USER_DEPARTMENT, EC_USER_DG, EC_USER_DISPLAY_NAME, EC_USER_ELK, EC_USER_OU, EXTRA_JAVA_PROPERTIES, FP_NO_HOST_CHECK, GRADLE_HOME, HOMEDRIVE, HOMEPATH, HTTP.PROXYHOST, HTTP.PROXYPASSWORD, HTTP.PROXYPORT, HTTP.PROXYUSER, HTTPS.PROXYHOST, HTTPS.PROXYPASSWORD, HTTPS.PROXYPORT, HTTPS.PROXYUSER, HTTPS_PROXY, HTTP_PROXY, JAVA_HOME, JAVA_OPTS, LDMS_LOCAL_DIR, LOCALAPPDATA, LOCALRUNSETUP, LOGONSERVER, M2, M2_HOME, M2_REPO, MAVEN_OPTS, MW_HOME, MYPROXY, NO_PROXY, NUMBER_OF_PROCESSORS, ORACLE_BASE, ORACLE_HOME, OS, PATH, PATH2, PATHEXT, PROCESSOR_ARCHITECTURE, PROCESSOR_IDENTIFIER, PROCESSOR_LEVEL, PROCESSOR_REVISION, PROGRAMDATA, PROGRAMFILES, PROGRAMFILES(X86), PROGRAMW6432, PROMPT, PSMODULEPATH, PUBLIC, SBT_HOME, SESSIONNAME, SFT_SOFTGRIDSERVER, SYSTEMDRIVE, SYSTEMROOT, TEMP, TMP, USERDNSDOMAIN, USERDOMAIN, USERDOMAIN_ROAMINGPROFILE, USERNAME, USERPROFILE, UUMDS.CONFIG.LOCATION, UUMDS_CFG, VAGRANT_HOME, VBOX_MSI_INSTALL_PATH, VSEDEFLOGDIR, WINDIR, WINDOWS_TRACING_FLAGS, WINDOWS_TRACING_LOGFILE]

如果从 maven 执行:请注意HTTP.PROXYUSER testEnvironment=[=::, =C:, =EXITCODE, ALLUSERSPROFILE, APPDATA, APR_ICONV_PATH, CHOCOLATEYBINROOT, CHOCOLATEYINSTALL, CHOCOLATEY_BIN_ROOT, CLASSPATH, CLASSWORLDS_JAR, CLASSWORLDS_LAUNCHER, CLINK_DIR, COMMANDER_DRIVE, COMMANDER_EXE, COMMANDER_INI, COMMANDER_PATH, COMMONPROGRAMFILES, COMMONPROGRAMFILES(X86), COMMONPROGRAMW6432, COMPUTERNAME, COMSPEC, DEBUGFLAG, DEBUG_PORT, DEFLOGDIR, EC_COMPUTER_OU, EC_HOMEAPPDATA, EC_USER_DEPARTMENT, EC_USER_DG, EC_USER_DISPLAY_NAME, EC_USER_ELK, EC_USER_OU, ERROR_CODE, EXEC_DIR, EXTRA_JAVA_PROPERTIES, FP_NO_HOST_CHECK, GRADLE_HOME, HOME, HOMEDRIVE, HOMEPATH, HTTP.PROXYHOST, HTTP.PROXYPASSWORD, HTTP.PROXYPORT, HTTP.PROXYUSER, HTTPS.PROXYHOST, HTTPS.PROXYPASSWORD, HTTPS.PROXYPORT, HTTPS.PROXYUSER, HTTPS_PROXY, HTTP_PROXY, JAVA_HOME, JAVA_OPTS, LDMS_LOCAL_DIR, LOCALAPPDATA, LOCALRUNSETUP, LOGONSERVER, M2, M2_HOME, M2_REPO, MAVEN_CMD_LINE_ARGS, MAVEN_JAVA_EXE, MAVEN_OPTS, MAVEN_PROJECTBASEDIR, MW_HOME, MYPROXY, NO_PROXY, NUMBER_OF_PROCESSORS, ORACLE_BASE, ORACLE_HOME, OS, PATH, PATH2, PATHEXT, PROCESSOR_ARCHITECTURE, PROCESSOR_IDENTIFIER, PROCESSOR_LEVEL, PROCESSOR_REVISION, PROGRAMDATA, PROGRAMFILES, PROGRAMFILES(X86), PROGRAMW6432, PROMPT, PSMODULEPATH, PUBLIC, SBT_HOME, SESSIONNAME, SFT_SOFTGRIDSERVER, SYSTEMDRIVE, SYSTEMROOT, TEMP, TMP, USERDNSDOMAIN, USERDOMAIN, USERDOMAIN_ROAMINGPROFILE, USERNAME, USERPROFILE, UUMDS.CONFIG.LOCATION, UUMDS_CFG, VAGRANT_HOME, VBOX_MSI_INSTALL_PATH, VSEDEFLOGDIR, WDIR, WINDIR, WINDOWS_TRACING_FLAGS, WINDOWS_TRACING_LOGFILE]

我在这里找到了类似的问题: Uppercase vs. capitalized environment variable names during debug [message #242568] ,但没有任何答案。

我在Windows 7和Eclipse v4.6(Neon)上使用Java 8.

>java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Eclipse Java EE IDE for Web Developers
Version: Neon Release (4.6.0)
Build id: 20160613-1800

> mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
Maven home: C:\costin\apps\apache-maven-3.3.3
Java version: 1.8.0_77, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_77\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

1 个答案:

答案 0 :(得分:1)

您没有使用JPDA进行调试。使用JPDA,您会看到System中使用的HashMap完全相同。您必须使用两个不同的VM执行,因为密钥的顺序不同,这不是100%的Java调试。

在两个不同的进程中,通过在环境变量之前使用系统属性,可以为执行提供不同的命名。