在ubuntu上安装jdk8-“无法找到软件包"更新无法解决 [英] Installing jdk8 on ubuntu- "unable to locate package" update doesn't fix

查看:280
本文介绍了在ubuntu上安装jdk8-“无法找到软件包"更新无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下载后,我一直在尝试在ubuntu上安装jdk.

I've been trying to install the jdk on my ubuntu after downloading it.

首先我用过:sudo apt-get update

然后:sudo apt-get install jdk*(因为我不想写整个长名).

then: sudo apt-get install jdk* (because I didn't want to write the whole long name).

它不起作用-将消息打印在标题中.

it didn't work- printed the message in the title.

我认为问题可能出在我正在执行的目录中(我已经从文件所在的下载目录中执行过该目录),因此我尝试从该目录中执行相同的命令(sudo apt-get install jdk*)主目录(根目录).然后,它开始工作..整个安装过程大约花了5分钟,看起来它正在安装很多我不需要的东西.

I thought the problem might me with the directory I'm executing from (I've executed it from the Downloads directory in which the file exists), so I've tried executing the same command (sudo apt-get install jdk*) from the home directory (root directory). Then it worked.. the whole installation took about 5 minutes and it looked like it was installing a lot of things I didn't ask for.

我不确定它是否安装了我需要的东西,我回到了jdk8软件包所在的Downloads目录,就像第一次从那里运行命令一样.与以前相同的消息...找不到包.

I wasn't sure it installed what I needed to I went back to the Downloads directory where the jdk8 package was located and like the first time ran the command from there. the same message as before... couldn't locate the package.

我做错了什么?显然,它没有安装,因为当我检查java(java -version)的版本时,它没有显示jdk8已安装.

What have I done wrong ? Obviously it wasn't installed because when I've checked the version of java (java -version) it didn't show jdk8 was installed.

感谢您抽出宝贵的时间阅读这一点:)

Thank you if you've taken the time to read to this point :)

推荐答案

命令行选项-Ubuntu

Command Line option - Ubuntu

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

然后在终端机

sudo apt-get install oracle-java8-installer

如果系统上有多个Java安装,则可以选择要用作默认Java版本.为此,请执行以下命令.

When there are multiple Java installations on your System, the Java version to use as default can be chosen. To do this, execute the following command.

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

编辑-手动安装Java

Edit - Manual Java Installation

下载oracle jdk

Download oracle jdk

http://www.oracle.com/technetwork/java/javase/downloads/index.html

将zip压缩到所需的文件夹中

Extract zip into desired folder

 e.g  /usr/local/  after extract /usr/local/jdk1.8.0_65

设置

sudo update-alternatives --install  /usr/bin/java java /usr/local/jdk1.8.0_65/bin/java 1
sudo update-alternatives --install  /usr/bin/javac javac /usr/local/jdk1.8.0_65/bin/javac 1
sudo update-alternatives --install  /usr/bin/javaws javaws /usr/local/jdk1.8.0_65/bin/javaws 1

sudo update-alternatives --set  java /usr/local/jdk1.8.0_65/bin/java
sudo update-alternatives --set  javac /usr/local/jdk1.8.0_65/bin/javac
sudo update-alternatives --set  javaws /usr/local/jdk1.8.0_65/bin/javaws

为外部应用程序(例如Eclipse和Idea)编辑/etc/environment设置JAVA_HOME路径

Edit /etc/environment set JAVA_HOME path for external applications like Eclipse and Idea

这篇关于在ubuntu上安装jdk8-“无法找到软件包"更新无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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