`
waitgod
  • 浏览: 18398 次
  • 性别: Icon_minigender_1
  • 来自: 济南
文章分类
社区版块
存档分类
最新评论

同样一段java代码,在eclipse的run模式与debug模式为什么结果会不一致??

 
阅读更多
package com.aking.test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;

public class TestEnv {
public static Properties getEnvVars() throws Throwable {
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
String OS = System.getProperty("os.name").toLowerCase();
// System.out.println(OS);
if (OS.indexOf("windows 9") > -1) {
p = r.exec("command.com /c set");
} else if (OS.indexOf("windows") > -1) {
// thanks to JuanFran for the xp fix!
p = r.exec("cmd.exe /c set");
} else {
// our last hope, we assume Unix (thanks to H. Ware for the fix)
p = r.exec("env");
}

BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
int idx = line.indexOf('=');
String key = line.substring(0, idx);
String value = line.substring(idx + 1);
envVars.setProperty(key, value);
System.out.println(line);
}
return envVars;
}

public static void main(String args[]) {
try {
Properties p = TestEnv.getEnvVars();
System.out.println("the current value of TEMP is : "
+ p.getProperty("TEMP"));
} catch (Throwable e) {
e.printStackTrace();
}
}
}

就这么一段代码,获取widows系统的环境变量,为什么debug模式下的结果与run模式下的结果会不一样呢?在run模式下是正常的,大小写区分的。但是在debug模式下,环境变量名称全成了大写???

在IntelliJ IDEA环境下验证同样的代码,run模式和debug模式得到的结果是一致的。因此推断,应该是eclipseIDE debug插件的问题。
分享到:
评论
1 楼 waitgod 2015-08-17  
在IntelliJ IDEA环境下验证同样的代码,run模式和debug模式得到的结果是一致的。因此推断,应该是eclipseIDE debug插件的问题。待有进展后再补充。

相关推荐

Global site tag (gtag.js) - Google Analytics