EC2 上的 Java 8 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24588742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 13:14:17  来源:igfitidea点击:

Java 8 application on EC2

javaamazon-web-servicesamazon-ec2

提问by Rune Aamodt

I was wondering if anyone knows if it will be possible for me to install Java 8 on an EC2 instance. My application is packed as a fat jar with embedded jetty, so the Java 8 runtime alone should be sufficient.

我想知道是否有人知道我是否可以在 EC2 实例上安装 Java 8。我的应用程序被打包成一个带有嵌入式码头的胖 jar,因此仅 Java 8 运行时就足够了。

I'm not too familiar with Linux, and I saw that they only had Java 7 support on the default AMI. Is there a simple command I can run to update to Java 8?

我对 Linux 不太熟悉,我看到他们在默认 AMI 上只支持 Java 7。我可以运行一个简单的命令来更新到 Java 8 吗?

采纳答案by slayedbylucifer

Java 8 may not be available out-of-the-box on the AMI that you are looking for. However, you can always install it once the instance is created.

Java 8 可能无法在您正在寻找的 AMI 上开箱即用。但是,您始终可以在创建实例后安装它。

e.g. Check this postwhich explains how to install java 8 on UbuntuOR check this postwhich explains how to install Java 8 on RHEL/Fedora/CentOS.

例如,检查这个职位,说明如何在安装Java 8Ubuntu或查看这篇文章,说明如何在安装Java 8 RHEL/Fedora/CentOS

回答by Damith Ganegoda

check Java current version

检查 Java 当前版本

java -version

install Java 1.8

安装 Java 1.8

sudo yum install java-1.8.0

change the Java version

更改 Java 版本

sudo alternatives --config java

回答by Praneeth

Installing JDK 8:

安装 JDK 8:

Step 1: Check the Java Version

步骤 1:检查 Java 版本

     java -version

Step 2: Download RPM package of Oracle JDK (8u121)

第二步:下载Oracle JDK的RPM包(8u121)

     wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept- 
     securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141- 
     b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm

Step 4: Install JDK 8

第 4 步:安装 JDK 8

     sudo yum install -y jdk-8u141-linux-x64.rpm

Step 5: Verify oracle JDK version

第五步:验证oracle JDK版本

     java -version

Installing JRE 1.8

安装 JRE 1.8

   sudo yum install java-1.8.0

change the Java version

更改 Java 版本

  sudo alternatives --config java

回答by Vikky

  1. Donwload Linux version of JRE from below link to your windows machine as it has browser. Note that if you are using this EC2 instance as server you just need JRE and not complete JDK. https://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html
  2. Tranfer downloaded .tar.gz file using winscp to your EC2 instance.
  3. Run "tar zxvf jre-8uversion-linux-i586.tar.gz" on your EC2 instance. For more info https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jre.html#CFHBHAGI
  1. 从下面的链接将 Linux 版本的 JRE 下载到您的 Windows 机器,因为它有浏览器。请注意,如果您将此 EC2 实例用作服务器,则您只需要 JRE 而不是完整的 JDK。 https://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html
  2. 使用 winscp 将下载的 .tar.gz 文件传输到您的 EC2 实例。
  3. 在您的 EC2 实例上运行“tar zxvf jre-8uversion-linux-i586.tar.gz”。更多信息https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jre.html#CFHBHAGI