无法获取环境,+ java.lang.ExceptionInInitializerError,Traceback IOError:File not found -

问题描述:

我在64位系统上运行Windows 7。 我使用NetBeans 6.9.1(Python的插件安装) 还安装:Python的2.7.1(64),JDK 6更新24(64),无法获取环境,+ java.lang.ExceptionInInitializerError,Traceback IOError:File not found -

我感兴趣的术语提取所以我下载montylingua它应该在Java或/和Python中运行。 这是链接:http://web.media.mit.edu/~hugo/montylingua/

当我尝试运行包含在现有的zip文件Sample.java代码,我遇到这些问题:

****** MontyLingua v.2.1 ****** 
***** by [email protected] ***** 
Failed to get environment, environ will be empty: (0, 'Failed to execute command ([\'sh\', \'-c\', \'env\']): 
java.io.IOException: Cannot run program "sh": CreateProcess error=2, The system cannot find the file specified') 

java.lang.ExceptionInInitializerError 
Caused by: Traceback (innermost last): 
    File "C:\work\montylingua-2.0\copy\JMontyLingua.py", line 0, in __init__ 
    File "C:\work\montylingua-2.0\copy\MontyLingua.py", line 0, in __init__ 
    File "C:\work\montylingua-2.0\copy\MontyLemmatiser.py", line 0, in __init__ 

IOError: File not found - 
    at org.python.core.Py.IOError(Py.java) 
    at org.python.core.PyFile._setup(PyFile.java) 
    at org.python.core.PyFile.<init>(PyFile.java) 
    at org.python.core.__builtin__.open(__builtin__.java) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java) 
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java) 
    at org.python.core.PyObject.__call__(PyObject.java) 
    at montylingua.MontyLemmatiser$_PyInner.__init__$5(MontyLemmatiser.java:5312) 
    at montylingua.MontyLemmatiser$_PyInner.call_function(MontyLemmatiser.java:5219) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyFunction.__call__(PyFunction.java) 
    at org.python.core.PyInstance.__init__(PyInstance.java) 
    at org.python.core.PyClass.__call__(PyClass.java) 
    at org.python.core.PyObject.__call__(PyObject.java) 
    at montylingua.MontyLingua$_PyInner.__init__$1(MontyLingua.java:218) 
    at montylingua.MontyLingua$_PyInner.call_function(MontyLingua.java:163) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyFunction.__call__(PyFunction.java) 
    at org.python.core.PyInstance.__init__(PyInstance.java) 
    at org.python.core.PyClass.__call__(PyClass.java) 
    at org.python.core.PyObject.__call__(PyObject.java) 
    at montylingua.JMontyLingua$_PyInner.__init__$1(JMontyLingua.java:85) 
    at montylingua.JMontyLingua$_PyInner.call_function(JMontyLingua.java:63) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyTableCode.call(PyTableCode.java) 
    at org.python.core.PyFunction.__call__(PyFunction.java) 
    at org.python.core.PyInstance.__init__(PyInstance.java) 
    at org.python.core.Py.initProxy(Py.java) 
    at montylingua.JMontyLingua.__initProxy__(JMontyLingua.java:256) 
    at montylingua.JMontyLingua.<init>(JMontyLingua.java:234) 
    at montylinguaapplication.MontySample.<clinit>(MontySample.java:8) 
Could not find the main class: montylinguaapplication.MontySample. Program will exit. 
Exception in thread "main" Java Result: 1 
BUILD SUCCESSFUL (total time: 3 seconds) 

我熟悉Java,因为我有一些小编程经验。我对Python一无所知。 我已经设置了程序运行所需的环境变量“MONTYLINGUA”。

我看到一篇关于Jython的帖子,其中有人得到和我一样的第一个错误,但我无法从所提出的任何事情做任何事情。 (其他帖子的链接:Jython - javaos.getenv() gives "Failed to get environment, environ will be empty"

任何能正确运行这个.java文件的人都可以推荐一些东西。

我也可以上传Java代码,但我认为这是过时的,因为它是可用的和容易中提到的网站上找到...

在我还包括了JyDT_Update_Site_1.4.15拉链项目,只是如果这会有所帮助,但不幸的是没有发生任何事情。

也许我必须在特定文件中添加一些代码,例如在其他文章的情况下,但我不知道在我的系统中添加什么。

谢谢你的时间。

在我看来,就像您链接的帖子一样。

'Failed to execute command ([\'sh\', \'-c\', \'env\']): java.io.IOException: Cannot run program "sh":

暗示jython被配置为认为它运行在某种UNIX系统上。

它看起来像python代码试图运行一个shell命令。 但是,既然你是在Windows上,这是行不通的。

它让我怀疑这是否真的是在python环境中使用的标准方法?

+0

我在jython的注册表文件中将'true'值更改为'false'(因为我还安装了jython)。没有什么改变... – Simos 2011-05-10 17:22:34

+0

也许是关于python,而不是jython(对不起,如果我错了,但我真的不知道这两者是如何相关的)。也许python有一个注册表文件(虽然我还没有找到它),在那里我可以添加一些代码或更改一些值.... – Simos 2011-05-10 17:24:58

+0

积极的一点是,我可以通过命令行在Python中运行应用程序没有任何错误,但这并不能帮助我达到我想要使用montylingua的目的。在java中通过命令行比以前有所进步,但仍然存在“错误”: ****** MontyLingua v.2.1 ****** ***** by [email protected]。 edu ***** Lemmatiser OK! Custom Lexicon Found!现在载入! 找到Fast Lexicon!现在载入! 词汇表OK! LexicalRuleParser OK! ContextualRuleParser OK! 线程“主”回溯(最里面的最后一个)的异常: 文件“C:\ work \ montylingua-2.0 \ copy \ MontyLingua.py”,行0,主 – Simos 2011-05-10 17:32:36

解决方法是在Jython 注册表文件中设置属性python.os

您可以按照以下说明找到注册表文件:http://www.jython.org/archive/21/docs/registry.html#finding

您需要在系统上安装Sun Java编译器1.4.2版。 如果没有它,您将无法运行MontyLingua Java示例,并且我们不确定您是否可以将MontyLingua编译为.NET DLL。 搜索www.sun.comfor Java SE开发工具包1.4.2版并安装 它。