降级在ubuntu 14.04中打开jdk 8到7 [英] Downgrade open jdk 8 to 7 in ubuntu 14.04

查看:208
本文介绍了降级在ubuntu 14.04中打开jdk 8到7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubuntu 14.04中意外升级了整个系统。



我正在尝试部署一个需要JDK7的war文件。



我试图安装JDK7并将其用作默认值

  root:floyd~#update-alternatives --config java 
链接组java中只有一个替代方法(提供/ usr / bin / java):/ usr / lib / jvm / java-8-openjdk-amd64 / jre / bin / java
没什么配置。

但它也没有安装。尝试安装JDK 7时出现以下错误。

  root @ floyd:〜#apt-get install openjdk-7-jdk 
阅读包列表...完成
构建依赖树
读取状态信息...完成
包openjdk-7-jdk不可用,但由另一个包引用。
这可能意味着包丢失,已经过时,或者
只能从其他来源获得

N:忽略文件'50unattended-upgrades.ucf-dist'in目录'/etc/apt/apt.conf.d/',因为它的文件扩展名无效
E:包'openjdk-7-jdk'没有安装候选者

我想我有两个选择。


  1. 安装JDK7并将其用作默认值。

  2. 将JDK8降级为JDK7。

我认为降级可能是一个不错的选择,但我无法做任何选择。

解决方案

在默认配置中安装JRE / JDK
OpenJDK 7默认安装在Ubuntu 12.10及更高版本中。
安装Java,其中apt-get很简单:

  sudo apt-get update 

java -version

如果执行后我们有类似的东西:程序java可以在下面找到包,这意味着没有安装Java。所以,我们需要:

  sudo apt-get install default-jre 

结果,将安装 Java运行时环境(JRE)。当我们想要安装 Java Development Kit(JDK)时,我们需要安装Java-app(例如,Apache Ant,Apache Maven,Eclipse和IntelliJ IDEA)要做的事情:

  sudo apt-get install default-jdk 

现在,安装了Java。



安装 OpenJDK 7 (可选)

  sudo apt-get install openjdk-7-jre 

执行后将安装Java运行时环境(JRE)。对于 Java Development Kit(JDK),我们执行:

  sudo apt -get install openjdk-7-jdk 






安装Oracle JDK(可选)
Oracle JDK是一个正式的JDK,但现在,Oracle不支持默认安装在Ubuntu中。



我们可以通过apt-get安装它,但在我们需要执行下一个命令之前:

  sudo apt-get install python -software-properties 
sudo add-apt-repository ppa:webupd8team / java
sudo apt-get update

稍后,我们必须选择所需的版本并执行:



对于Oracle JDK 6

  sudo apt-get install oracle-java6-installer 

对于Oracle JDK 7

  sudo apt-get install oracle-java7-installer 

对于Oracle JDK 8

  sudo apt-get install甲骨文JA va8-installer 

对于Oracle JDK 9

  sudo apt-get install oracle-java9-installer 

管理Java(可选)
当我们安装了某个版本的Java时,我们可以选择其中一个作为默认值:

  sudo update-alternatives --config java 

结果我们会看到像这个:

 备用java有两种选择(提供/ usr / bin / java)。 

选择路径优先级状态
---------------------------------- --------------------------
* 0 / usr / lib / jvm / java-7-oracle / jre / bin / java 1062自动模式
1 / usr / lib / jvm / java-6-openjdk-amd64 / jre / bin / java 1061手动模式
2 / usr / lib / jvm / java-7-oracle / jre / bin / java 1062手动模式

按Enter键保留当前选项[*]或类型选择号:

我们可以在屏幕上看到它:



现在,我们需要重新启动此文件:

  source / etc / environment 

要检查它我们可以:

  echo $ JAVA_HOME 

在屏幕上:



我们现在有了输入方式(在我们的示例中为/ usr / lib / jvm / java-7-oracle)它将意味着我们成功地完成它。换句话说,我们需要更加专心,并检查所有这些步骤。


I accidentally upgraded the whole system in ubuntu 14.04.

I am trying to deploy a war file which requires JDK7.

I tried to install JDK7 and use it as default

root:floyd~# update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Nothing to configure.

but it is not installing as well. It gives following error while trying to install JDK 7.

root@floyd:~# apt-get install openjdk-7-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package openjdk-7-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

N: Ignoring file '50unattended-upgrades.ucf-dist' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension
E: Package 'openjdk-7-jdk' has no installation candidate

I guess I have two options.

  1. Install JDK7 and use it as default.
  2. Downgrade JDK8 to JDK7.

I think downgrading can be a good option but I am not able to do any of them.

解决方案

Installing JRE/JDK in default configuration OpenJDK 7 is installed as default in Ubuntu 12.10 and later. Installing Java whereby apt-get is easy:

sudo apt-get update

java -version

If after execution we have something like: "The program java can be found in the following packages", it means that Java isn't installed. So, we need to to:

sudo apt-get install default-jre

As result, Java Runtime Environment (JRE) will be installed. When we want to install Java Development Kit (JDK), which is needed for compilling Java-app (for example, Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA) we need to do:

sudo apt-get install default-jdk

Now, Java is installed.

Installing OpenJDK 7 (optionally)

sudo apt-get install openjdk-7-jre

After execution Java Runtime Environment (JRE) will be installed. For Java Development Kit (JDK), we execute:

sudo apt-get install openjdk-7-jdk


Installing Oracle JDK (optionally) Oracle JDK is an official JDK but, now, Oracle doesn't support it like default for installation in Ubuntu.

We can install it by apt-get but before we need to execute next commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Later, we have to choose needed version and execute:

For Oracle JDK 6

sudo apt-get install oracle-java6-installer

For Oracle JDK 7

sudo apt-get install oracle-java7-installer

For Oracle JDK 8

sudo apt-get install oracle-java8-installer

For Oracle JDK 9

sudo apt-get install oracle-java9-installer

Managing of Java (optionally) When we have some version Java installed we can choose one of them as default:

sudo update-alternatives --config java

As result we will see something like this:

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

We can see it on the screen:

The same action we can do to choose the compiler (javac):

sudo update-alternatives --config javac

This command can be used to choose other java componenst, for example, like: keytool, javadoc and jarsigner.

Installing "JAVA_HOME" To be installed **JAVA_HOME**:

sudo update-alternatives --config java

Result like:

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1062      manual mode

Press enter to keep the current choice[*], or type selection number:

As we can see the paths for java will be:

/usr/lib/jvm/java-7-oracle
/usr/lib/jvm/java-6-openjdk-amd64
/usr/lib/jvm/java-7-oracle

Now, we need to copy one of the ways and paste it into: /etc/environment:

sudo nano /etc/environment

In the file we are going to add a path(where YOUR_PATH - is path for desired version of java, for example: "/usr/lib/jvm/java-7-oracle"):

JAVA_HOME="/usr/lib/jvm/java-7-oracle"

On the screen:

Now, we need to reboot this file:

source /etc/environment

To check it we can:

echo $JAVA_HOME

On the screen:

When we have, now, input way("/usr/lib/jvm/java-7-oracle" in our example) it will be means we do it sucessfully. In other way we need to be more attentive and check all these steps once.

这篇关于降级在ubuntu 14.04中打开jdk 8到7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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