问题描述
每当我在Eclipse中运行任何jython程序时,在输出的开头都会出现以下错误:
Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output:
首先,我的环境是:
Windows 2008
Windows 2008
JDK 1.6.0u10
JDK 1.6.0u10
jython 2.2.1
jython 2.2.1
我做了一些挖掘,然后才意识到此消息是在函数javaos.getenv()中产生的.每当我调用javaos.getenv()函数时,它都会引发以下错误:
I did some digging, and I realized that this message is produced in the function javaos.getenv(). Whenever I call the javaos.getenv() function, it throws the following error:
C:\ jython2.2.1> java -jar jython.jar
C:\jython2.2.1>java -jar jython.jar
打印javaos.getenv("user.name")
print javaos.getenv("user.name")
无法获取环境,环境 将为空:(0,'执行失败 命令([\'sh \',\'-c \',\'env \']): java.io.IOException:无法运行 程序"sh":Crea teProcess error = 2, 系统找不到文件 指定")
Failed to get environment, environ will be empty: (0, 'Failed to execute command ([\'sh\', \'-c\', \'env\']): java.io.IOException: Cannot run program "sh": Crea teProcess error=2, The system cannot find the file specified')
这很奇怪,因为我当前使用的是Windows计算机,而不是Unix.
This is strange, because I'm currently using a Windows machine, not an Unix.
推荐答案
尝试取消注释并更改注册表"文件中的os设置
Try to uncomment and change the os setting in the 'registry' file
(与您的jython.jar位于同一目录,我希望如此)
(it is in the same directory as your jython.jar / i hope)
# python.os determines operating-specific features, similar to and overriding the
# Java property "os.name".
# Some generic values are also supported: 'nt', 'ce' and 'posix'.
# Uncomment the following line for the most generic OS behavior available.
#python.os=None
python.os=nt
# try nt or dos
这篇关于Jython-javaos.getenv()给出“无法获取环境,环境将为空".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!