Cordova无法与Java 9一起使用.如何仅为Cordova设置特定的jdk? [英] Cordova isn't working with Java 9. How to set a specific jdk ONLY for Cordova?

查看:212
本文介绍了Cordova无法与Java 9一起使用.如何仅为Cordova设置特定的jdk?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于当前此问题科尔多瓦无法在Java 9上运行(如果我错了,请纠正我).

Due to this issue, at the moment Cordova isn't able to run on Java 9 (please correct me if I'm wrong).

此处讨论了类似的问题,但是建议的解决方案涉及删除Java 9或将JAVA_HOME环境变量重置为指向Java 8,但是这两者都有副作用,即所有其他Java应用程序都将在Java 8上运行.

A similar question was discussed here, but the proposed solutions involve the removal of Java 9, or the reset of the JAVA_HOME environment variable to point to Java 8, but both has the side effect that all the other Java applications will run on Java 8.

那么,如何将Cordova设置为使用Java 8,而其余应用程序仍在Java 9上?

So how do you set Cordova to use Java 8, having the rest of applications still on Java 9?

推荐答案

...将JAVA_HOME环境变量重置为指向Java 8,但是[副作用]是所有其他Java应用程序都将在Java 8上运行.

... the reset of the JAVA_HOME environment variable to point to Java 8, but [that] has the side effect that all the other Java applications will run on Java 8.

只有做错方法了!

创建一个包含该文件的文件(例如mycordova.sh),使其可执行,并将其放在外壳程序的命令搜索路径中.

Create a file (say mycordova.sh) containing this, make it executable and put it on your shell's command search path.

#!/bin/sh
export JAVA_HOME=/path/to/java8/home
cordova "$@"

运行该命令可以使用Java 8 来运行cordova,而不会干扰其他应用程序.

Running that command runs cordova using Java 8 without interfering with other applications.

更新-如果建议的解决方法是使用alternatives进行更改,则表明cordova启动器/脚本未使用JAVA_HOME查找java命令.您也可以处理.有两种可能:

UPDATE - If the work-around proposed is to use alternatives to change, that means that the cordova launcher / script, is not using JAVA_HOME to find the java command. You can deal with that too. There are a couple of possibilities:

  • 如果cordova是包装脚本,则将其复制并编辑以使用要使用的java命令(等)的版本.

  • If cordova is a wrapper script, then copy it and edit it to use the version of the java command (etc) that you want to use.

否则,请在mycordova.sh脚本中(请参见上文)更新PATH变量,以使Java 8 JRE的bin目录位于包含java链接的目录的前面,该链接包含管理.只要标准的科尔多瓦发射器没有硬接线/usr/bin/java

If not then in your mycordova.sh script (see above) also update the PATH variable so that the Java 8 JRE's bin directory is ahead of the directory containing the java link that alternatives manages. That will work ... provided that the standard cordova launcher has not hard wired /usr/bin/java

更新2 -mycordova.sh的最终脚本是:

UPDATE 2 - Final script for mycordova.sh is:

#!/bin/sh
export JAVA_HOME=/path/to/java8/home
export PATH=/path/to/java8/bin/:$PATH
cordova "$@"

这篇关于Cordova无法与Java 9一起使用.如何仅为Cordova设置特定的jdk?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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