Jython安装小坎坷
背景
由于要使用MonkeyRunner需要Jython,所以讲一下Android过程中的坎坷。
软件各配置
操作系统:Windows 7 64位
Java 版本: 1.8.3
Python版本:2.7.8
安装过程
一开始就去Jython 官网下载最新的Jython版本,下载下来之后是个.jar包。
在 cmd 中直接用java -jar + jar包
命令安装就行
遇到的问题
使用最新版的 Jython 安装之后,cmd中报错,提示Error loading python27.dll (error code 14001)
,搜索引擎搜了一下,在stackoverflow上找到了原因。原来是Jython2.7.1不支持Windows 7,只能去下载2.7.0或更低的版本。在这里找到了2.7.0,下载了jar包。
还是和前面一样,在 cmd 中直接用java -jar + jar包
命令安装。
这次安装又报错了,报错内容如下:
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.8', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
这个不用搜索引擎就知道是java太高了,哎,没办法,只好把电脑中系统的环境变量里面Java改成1.7的。
本以为就这样就会好了的、
没想到,改了Java版本之后重新安装还是这个提示,我就纳闷了。明明在cmd用java -version 看过Java版本啦,是1.7啊。为什么还是不行?没办法,只能再求助搜索引擎。 [结果](https://stackoverflow.com/questions/29697543/registry-key-error-java-version-has-value-1-8-but-1-7-is-required)在这找到了答案:
原因是系统路径中Windows\System32
或者Windows\SysWOW64
这里面有java.exe
,javaw.exe
, javaws.exe
这几个文件,这几个还是1.8.3的。
这里我猜是缓存,虽然环境变量已经改变,但是这路径里面的还未被更改。
最后
最后终于成功装上了,要检验装上没有,需要配置一下环境变量。jython.exe·的路径在安装路径的/bin文件中。 配置完跟Python一样,直接在cmd中输入
jython`,看看是否进入Jython就欧了。
插曲
中间在一开始安装不成功时,我先是去官网上看官方的安装指导。
结果看到一参数,java -jar jython-installer-2.7.1.jar --help
我发现,-help或者–help是挺好用的,有时候不知道什么命令的时候,可以在后面敲上这个参数,看看有没有用。【嘻嘻】
usage:
java -jar jython-installer-2.7.0.jar [-c | -s | -A] [-d dir] [-t type] [-i
part(s)] [-e part(s)] [-v] [-h | -?]
No option at all will start the interactive GUI installer, except:
Options respected in GUI mode are 'directory', which serve as default values
in the wizard.
In non-GUI mode the following options are available:
-c,--console console based installation (user interaction)
any other options will be ignored (except 'verbose')
-s,--silent silent installation (without user interaction)
-A,--autotest automatic stress tests for the installer
most of the other options are ignored
allowed additional options: 'verbose
-d,--directory <dir> target directory to install to
(required in silent mode,
used as default in GUI mode)
-t,--type <type> installation type
one of the following types is possible
(see also include/exclude parts):
- all: everything (including src)
- standard: core, mod, demo, doc, ensurepip
standard is the default
- minimum: core
- standalone: install a single, executable .jar,
containing all the modules
-i,--include <part(s)> finer control over parts to install
more than one of the following is possible:
- mod: library modules
- demo: demos and examples
- doc: documentation
- src: java source code
- ensurepip: install pip and setuptools
-e,--exclude <part(s)> finer control over parts not to install
more than one of the following is possible:
- mod: library modules
- demo: demos and examples
- doc: documentation
- src: java source code
- ensurepip: install pip and setuptools
(excludes override includes)
-v,--verbose print more output during the installation
(also valid in GUI and autotest mode)
-h,--help print this help (overrides any other options)
-? print this help (overrides any other options)
example of a GUI installation:
java -jar jython-installer-2.7.0.jar
example of a console installation:
java -jar jython-installer-2.7.0.jar -c
example of a silent installation:
java -jar jython-installer-2.7.0.jar -s -d targetDirectory
examples of a silent installation with more options:
java -jar jython-installer-2.7.0.jar -s -d targetDirectory -t minimum -i src
java -jar jython-installer-2.7.0.jar -s -d targetDirectory -t standard -e demo doc -i src
example of an autotest installation into temporary directories:
java -jar jython-installer-2.7.0.jar -A
(uses java.awt.Robot; make sure you do NOT touch mouse NOR keyboard
after hitting enter/return!)
最后我安装时特意不用图形界面安装,使用-c用控制台安装,发现要选择的选项比图形界面多,在这就不展开了。
有兴趣自己的去尝试。