jEdit Python Shell插件无法运行Python3(如何更新.jar存档中的文件?) [英] jEdit Python Shell plugin fails to run Python3 (How to update a file in a .jar archive?)

查看:120
本文介绍了jEdit Python Shell插件无法运行Python3(如何更新.jar存档中的文件?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我感到困惑的是,用于jEdit的Python Shell插件如何不适用于Python3?自2012年以来,这个问题似乎就已广为人知,而且显然没有人提供更新版本(

What puzzles me is, how does it come that the Python Shell plug-in for jEdit does not work with Python3? The issue seem to be known since year 2012 and apparently no one has yet provided an updated version ( http://www.jedit.org/oldtrackers/Plugin%20Feature%20Requests/3498547.html ) of this plug-in working for both Python2.x and Python3.x . Am I alone with the need of having this plug-in up an running in jEdit?

问题在于此插件使用了execfile()函数,而该函数在Python3中不可用.为了提供修复,有必要在此插件的PythonShell.java代码中进行替换:

The problem is that this plug-in uses the execfile() function which is not available in Python3. In order to provide a fix it is necessary to replace in PythonShell.java code of this plugin:

    execfile("filename")

    exec( open("filename").read() )

对于不熟悉Java的我来说,很难从调整后的PyhonShell.java文件中获取更新的PythonShell.jar. 解决问题成功后,我仍然不明白的是如何使用jar.经过多种方法,我终于想到了:

For me who is not very familiar with Java it was very hard to get an updated PythonShell.jar out of the adjusted PyhonShell.java file. What I still fail to understand after success with fixing the problem is how to use jar. After many various approaches I came finally out with:

    jar -u PythonShell.jar -C python/shell  PythonShell.class

但这也给了我与我一直得到的相同的东西:

but also this gave me the same as I was getting all the time:

     jar: `-u' mode requires a file name

jar的-help不能帮助我理解我用从编译的ShellShell.java文件获得的新版本替换PythonShell.jar中的PythonShell.class文件的所有尝试中做错了什么.

The jar's -help was not able to help me understand what I did wrong in all my attempts to replace the PythonShell.class file in the PythonShell.jar with the new version got from compiled PythonShell.java file.

我的解决方法是将.jar重命名为.zip,使用文件管理器将PythonShell.class文件放入其中,然后将其重命名为.jar,但我很高兴摆脱了不了解"jar"命令的工作方式.

My workaround was to rename the .jar to .zip, put the PythonShell.class file into it using a File Manager and then rename it back to .jar, but I would be glad to get rid of the bad gut feeling of not understanding how the 'jar' command works.

推荐答案

默认情况下,jar命令以流模式工作.这意味着如果您执行jar -c foo,它将使用文件foo从中创建一个JAR,并将其输出到stdout.然后,您可以将其重定向到文件(jar -c foo >foo.jar),也可以使用-f指示jar创建文件(jar -cf foo.jar foo).

The jar command by default works in streamed mode. This means if you do jar -c foo, it takes the file foo creates a JAR out of it and outputs it to stdout. You can then either redirect this to a file (jar -c foo >foo.jar), or you can use -f to instruct jar to create a file (jar -cf foo.jar foo).

在更新JAR文件时也是如此,您可以像cat foo.jar | jar -u foo >foo2.jar一样流式传输输入和输出,也可以使用-f指示它像jar -uf foo.jar foo那样就地更新文件.

The same applies when updating a JAR file, you can either stream the input in and the output out like cat foo.jar | jar -u foo >foo2.jar or you can use -f to instruct it to update the file in place like jar -uf foo.jar foo.

如果您告诉它使用-u更新文件,但没有指定要使用-f更新的文件,并且没有在stdin上提供任何内容,则该文件将无法工作,因为它不知道要使用哪个文件更新.

If you tell it to update a file using -u, but you don't specify which file to update with -f and are not giving anything on stdin, then it cannot work as it does not know what file to update.

PS:欢迎您向 https://sourceforge.net/p提交补丁/jedit/plugin-patches 供插件维护者接受,或者在没有活动维护者且您想超越的情况下超过插件维护.

PS: You are welcome to submit a patch to https://sourceforge.net/p/jedit/plugin-patches for the plugin maintainer to accept, or overtake maintenance of the plugin if there is no active maintainer and you want to overtake.

这篇关于jEdit Python Shell插件无法运行Python3(如何更新.jar存档中的文件?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆