In this guide, you will install various versions of the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) using apt.
In this guide, you will install various versions of the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) using apt.Introduction
You'll install OpenJDK as well as official packages from Oracle. You'll then select the version you wish to use for your projects. When you're finished, you'll be able to use the JDK to develop software or use the Java Runtime to run software.Prerequisites
To follow this tutorial, you will need:
The easiest option for installing **Java **is to use the version packaged with Ubuntu. By default, Ubuntu 18.04 includes Open JDK, which is an open-source variant of the **JRE **and JDK.
This package will install either OpenJDK 10 or 11.
To install this version, first update the package index:
sudo apt update
Next, check if Java is already installed:
If Java is not currently installed, you'll see the following output:
Output Command 'java' not found, but can be installed with: apt install default-jre apt install openjdk-11-jre-headless apt install openjdk-8-jre-headless apt install openjdk-9-jre-headless
Execute the following command to install OpenJDK:
sudo apt install default-jre
This command will install the Java Runtime Environment (JRE). This will allow you to run almost all Java software.
Verify the installation with:
You'll see the following output:
Output openjdk version "10.0.1" 2018-04-17 OpenJDK Runtime Environment (build 10.0.1+10-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 10.0.1+10-Ubuntu-3ubuntu1, mixed mode)
You may need the Java Development Kit (JDK) in addition to the JRE in order to compile and run some specific Java-based software. To install the JDK, execute the following command, which will also install the JRE:
sudo apt install default-jdk
Verify that the JDK is installed by checking the version of
javac, the Java compiler:
You'll see the following output:
Output javac 10.0.1
Next, let's look at specifying which OpenJDK version we want to install.Installing Specific Versions of OpenJDK
While you can install the default OpenJDK package, you can also install different versions of OpenJDK.
Java 8 is the current Long Term Support version and is still widely supported, though public maintenance ends in January 2019. To install OpenJDK 8, execute the following command:
sudo apt install openjdk-8-jdk
Verify that this is installed with
You'll see output like this:
Output openjdk version "1.8.0_162" OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-1-b12) OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)
It is also possible to install only the JRE, which you can do by executing
sudo apt install openjdk-8-jre.
Ubuntu's repositories contain a package that will install either Java 10 or 11. Prior to September 2018, this package will install OpenJDK 10. Once Java 11 is released, this package will install Java 11.
To install OpenJDK 10/11, execute the following command:
sudo apt install openjdk-11-jdk
To install the JRE only, use the following command:
sudo apt install openjdk-11-jre
Next, let's look at how to install Oracle's official JDK and JRE.Installing the Oracle JDK
If you want to install the Oracle JDK, which is the official version distributed by Oracle, you'll need to add a new package repository for the version you'd like to use.
To install Java 8, which is the latest LTS version, first add its package repository:
sudo add-apt-repository ppa:webupd8team/java
When you add the repository, you'll see a message like this:
output Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK8). There are no actual Jav a files in this PPA. Important -> Why Oracle Java 7 And 6 Installers No Longer Work: http://www.webupd8.org/2017/06/why-oracl e-java-7-and-6-installers-no.html Update: Oracle Java 9 has reached end of life: http://www.oracle.com/technetwork/java/javase/downloads/j dk9-downloads-3848520.html The PPA supports Ubuntu 18.04, 17.10, 16.04, 14.04 and 12.04. More info (and Ubuntu installation instructions): - for Oracle Java 8: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html Debian installation instructions: - Oracle Java 8: http://www.webupd8.org/2014/03/how-to-install-oracle-java-8-in-debian.html For Oracle Java 10, see a different PPA: https://www.linuxuprising.com/2018/04/install-oracle-java-10-in-ubuntu-or.html More info: https://launchpad.net/~webupd8team/+archive/ubuntu/java Press [ENTER] to continue or Ctrl-c to cancel adding it.
ENTER to continue. Then update your package list:
sudo apt update
Once the package list updates, install Java 8:
sudo apt install oracle-java8-installer
Your system will download the JDK from Oracle and ask you to accept the license agreement. Accept the agreement and the JDK will install.
Now let's look at how to select which version of Java you want to use.Managing Java
You can have multiple Java installations on one server. You can configure which version is the default for use on the command line by using the
sudo update-alternatives --config java
This is what the output would look like if you've installed all versions of Java in this tutorial:
Output There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode 3 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode
Choose the number associated with the Java version to use it as the default, or press
ENTER to leave the current settings in place.
You can do this for other Java commands, such as the compiler (
sudo update-alternatives --config javac
Other commands for which this command can be run include, but are not limited to:
Many programs written using Java use the
JAVA_HOME environment variable to determine the Java installation location.
To set this environment variable, first determine where Java is installed. Use the
sudo update-alternatives --config java
This command shows each installation of Java along with its installation path:
Output There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode 2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode 3 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode Press <enter> to keep the current choice[*], or type selection number:
In this case the installation paths are as follows:
Copy the path from your preferred installation. Then open
nano or your favorite text editor:
sudo nano /etc/environment
At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path:
Modifying this file will set the
JAVA_HOME path for all users on your system.
Save the file and exit the editor.
Now reload this file to apply the changes to your current session:
Verify that the environment variable is set:
You'll see the path you just set:
Other users will need to execute the command
source /etc/environment or log out and log back in to apply this setting.
In this tutorial you installed multiple versions of Java and learned how to manage them. You can now install software which runs on Java, such as Tomcat, Jetty, Glassfish, Cassandra or Jenkins.
java.lang.UnsupportedOperationException: HTTP upgrade is not supported by this protocol at org.apache.coyote.AbstractProcessor.doHttpUpgrade(AbstractProcessor.java:712) ~[tomcat-coyote.jar:8.5.20] at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:478) ~[tomcat-coyote.jar:8.5.20] at org.apache.coyote.Request.action(Request.java:433) ~[tomcat-coyote.jar:8.5.20] at org.apache.catalina.connector.Request.upgrade(Request.java:2022) ~[catalina.jar:8.5.20] at org.apache.catalina.connector.RequestFacade.upgrade(RequestFacade.java:1115) ~[catalina.jar:8.5.20] at org.apache.tomcat.websocket.server.UpgradeUtil.doUpgrade(UpgradeUtil.java:234) ~[tomcat-websocket-8.5.20.jar:8.5.20] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:77) ~[tomcat-websocket-8.5.20.jar:8.5.20] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.20] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.20] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) [catalina.jar:8.5.20] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.20] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.20] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.20] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) [catalina.jar:8.5.20] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.20] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.20] at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:486) [tomcat-coyote.jar:8.5.20] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.20] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.20] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457) [tomcat-coyote.jar:8.5.20] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.20] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_11] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_11] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.20] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_11]
I did some research and stumbled on someone who had a similar problem and asked in this question WebSockets through Apache and Tomcat: HTTP upgrade is not supported by the AJP protocol but am running a private tomcat instance on a shared hosting server so the solutions provided in that answer cannot be achieved by me hence i contact my host and they respond with
'While investigating your query, we could see that making changes in the tomcat and HTTP settings as per the steps mentioned in your email will affect the AJP connection configuration of another shared tomcat instance and the applications hosted by the shared tomcat instance will not work. For re-compiling, the connector settings also need a server-wide update and this cannot be done in a shared server environment. We request you to try our VPS plans by visiting the below link.'
I think purchasing a vps plan should be a last resort. Is there anyone here with a more conducive solution to the problem.
This video will help you understand and learn Apache Spark in detail. This Spark tutorial is ideal for both beginners as well as professionals who want to master Apache Spark concepts.
This video will help you understand and learn Apache Spark in detail. This Spark tutorial is ideal for both beginners as well as professionals who want to master Apache Spark concepts. Below are the topics covered in this Spark tutorial for beginners:
2:44 Introduction to Apache Spark
3:49 What is Spark?
5:34 Spark Eco-System
7:44 Why RDD?
16:44 RDD Operations
18:59 Yahoo Use-Case
21:09 Apache Spark Architecture
26:59 Spark Architecture
39:54 Spark RDD
41:09 Spark Applications
41:59 Need For RDDs
43:34 What are RDDs?
44:24 Sources of RDDs
45:04 Features of RDDs
46:39 Creation of RDDs
50:19 Operations Performed On RDDs
50:49 Narrow Transformations
51:04 Wide Transformations
51:44 RDDs Using Spark Pokemon Use-Case
1:05:19 Spark DataFrame
1:06:54 What is a DataFrame?
1:08:24 Why Do We Need Dataframes?
1:09:54 Features of DataFrames
1:11:09 Sources Of DataFrames
1:11:34 Creation Of DataFrame
1:24:44 Spark SQL
1:25:14 Why Spark SQL?
1:27:09 Spark SQL Advantages Over Hive
1:31:54 Spark SQL Success Story
1:33:24 Spark SQL Features
1:37:15 Spark SQL Architecture
1:39:40 Spark SQL Libraries
1:42:15 Querying Using Spark SQL
1:45:50 Adding Schema To RDDs
1:55:05 Hive Tables
1:57:50 Use Case: Stock Market Analysis with Spark SQL
2:16:50 Spark Streaming
2:18:10 What is Streaming?
2:25:46 Spark Streaming Overview
2:27:56 Spark Streaming workflow
2:31:21 Streaming Fundamentals
2:38:56 Input DStreams
2:40:11 Transformations on DStreams
2:43:06 DStreams Window
2:49:06 Broadcast Variables
2:51:11 Use-Case Twitter Sentiment Analysis
3:00:26 Spark MLlib
3:00:31 MLlib Techniques
3:11:51 Use Case: Earthquake Detection Using Spark
3:24:01 Visualizing Result
3:25:11 Spark GraphX
3:26:01 Basics of Graph
3:27:56 Types of Graph
3:40:42 Property Graph
3:48:37 Creating & Transforming Property Graph
3:56:17 Graph Builder
4:02:22 Vertex RDD
4:07:07 Edge RDD
4:11:37 Graph Operators
4:24:37 GraphX Demo
4:34:24 Graph Algorithms
4:38:29 Connected Components
4:40:39 Triangle Counting
4:44:09 Spark GraphX Demo
4;57:54 MapReduce vs Spark
5:13:03 Kafka with Spark Streaming
5:23:38 Messaging System
5:21:15 Kafka Components
2:23:45 Kafka Cluster
5:48:56 Kafka Spark Streaming Demo
6:17:16 PySpark Tutorial
6:21:26 PySpark Installation
6:47:06 Spark Interview Questions