Jython安裝小坎坷

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.exejavaw.exejavaws.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用控制檯安裝,發現要選擇的選項比圖形界面多,在這就不展開了。
有興趣自己的去嘗試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章