Contents
How to increase maximum heap size of JVM in ubuntu.......................................................................................................1
How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux Mint 19/18........................................................................................3
Step 1 – Install Java 8 on Ubuntu...........................................................................................................................................4
Step 2 – Verify Java Installation.............................................................................................................................................4
Step 3 – Setup JAVA_HOME and JRE_HOME Variable..............................................................................................................4
How To Install Java with Apt on Ubuntu 18.04.....................................................................................................................5
Introduction..................................................................................................................................................................5
Prerequisites..................................................................................................................................................................... 6
Installing the Default JRE/JDK...........................................................................................................................................6
Installing Oracle JDK 11....................................................................................................................................................7
Managing Java................................................................................................................................................................10
Setting the JAVA_HOME Environment Variable...............................................................................................................11
Conclusion...................................................................................................................................................................... 12
How to Download and Install Oracle JAVA 8 on Ubuntu 18.04/16.04 LTS..........................................................................12
Introduction........................................................................................................................................................................ 12
Java 8 Features:...........................................................................................................................................................12
Prerequisites....................................................................................................................................................................... 12
Step 1: Download Oracle Java 8.....................................................................................................................................13
Step 2: Copy downloaded Setup and Extract..................................................................................................................14
Step 3: Install Oracle Java 8 on ubuntu with Alternatives...............................................................................................14
Step 4: Verify Update Alternatives.................................................................................................................................15
Step 5: Setting the JAVA_HOME and JRE_HOME Environment Variables.................................................................16
Step 6: Verify Java Version............................................................................................................................................16
Conclusion.......................................................................................................................................................................... 17
Before you Begin..........................................................................................................................................................17
Install Alien.................................................................................................................................................................... 17
Converting and Installing an RPM package.............................................................................................................18
Installing an RPM package directly............................................................................................................................18
How to increase maximum heap size of JVM in
ubuntu
Hemanthi Wimalasiri
Follow
Oct 26, 2018 · 2 min read
As developers you have to work with IDEs to make your life easy. But there
comes a problem of getting your machine stuck when using these tools.
Specially when using Jetbrains IDEs. This is caused mainly due to the lack of
heap memory in your JVM. You may not be using your RAM to its full
capacity because the maximum heap size is set to a lower value by default.
So I’m gonna tell you today on how to increase that default max heap size in
few easy steps.
First to check the default value, run this command on your linux terminal
$ java -XshowSettings:vm
So as you can see, it is set to a value near to 1GB by default. In order to
increase that permanently you need to change /etc/profile file.
Run this command in order to edit that file (Hope you are familiar with
using vim)
$ sudo vim /etc/profile
And add this line to the beginning of the file,
export _JAVA_OPTIONS=-Xmx2048m
(If you want to increase it to some other value, replace 2048 with the
appropriate value in MB).
Now log out from your account and log in again.
Run the previous command again to check whether it has changed.
$ java -XshowSettings:vm
As you can see, now it has been changed. So that’s it!
Hope this would be helpful to you.
=============================================================================================
How to Install JAVA 8 on Ubuntu 18.04/16.04, Linux
Mint 19/18
Written by Rahul, Updated on May 28, 2020
There are two standard types of installation available are JDK and JRE. JDK (Java
Development Kit) provides the ability to develop a new Java application, which
includes Java compiler. JRE (Java Runtime Environment) provides the runtime
environment for any Java application with applets. The Java developers required
to install JDK and JRE both on their system to create new Java Applications.
IMPORTANT: The Oracle Java 8 is no longer available to download publicaly. You can use below
link to install Java 11. You may also continue to this tutorial to install OpenJDK 8.
Read this => Install Oracle Java 11 on Ubuntu 16.04 LTS (Xenial)
Read this => Install Oracle Java 11 on Ubuntu 18.04 LTS (Bionic)
Use this tutorial to install OpenJDK Java 8 on Ubuntu 19.10, 18.04 LTS, 16.04
LTS, LinuxMint 19, 18 using PPA. Follow the below steps to install Java 8 on
Ubuntu via the command line.
Step 1 – Install Java 8 on Ubuntu
The OpenJDK 8 is available under default Apt repositories. You can simply install
Java 8 on an Ubuntu system using the following commands.
Run below commands to install Java 8 on Ubuntu and LinuxMint.
sudo apt update
sudo apt install openjdk-8-jdk openjdk-8-jre
Step 2 – Verify Java Installation
You have successfully installed Java 8 on your system. Let’s verify the installed
and current active version using the following command.
java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
Step 3 – Setup JAVA_HOME and JRE_HOME Variable
As you have installed Java on your Linux system, You must have to
set JAVA_HOME and JRE_HOME environment variables, which is used by many of
the Java applications to find Java libraries during runtime. You can set these
variables in /etc/environment file using the following command.
cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
EOL
All done, you have successfully installed Java 8 on a Linux system. You may also
need to install Tomcat server to run your Java web application. Use our another
tutorial to Install Tomcat 7 or Install Tomcat 8 or Install Tomcat 9 on Ubuntu,
Debian, and LinuxMint systems.
===============================================================================================
How To Install Java with Apt on Ubuntu 18.04
JavaUbuntu 18.04
By Koen Vlaswinkel
UpdatedMay 7, 2020 1.7mviews
English
English
Not using Ubuntu 18.04?
Choose a different version or distribution.
Ubuntu 18.04
Ubuntu 18.04
See More
The author selected the Open Internet/Free Speech Fund to receive a $100 donation as part of
the Write for DOnations program.
Introduction
Java and the JVM (Java’s virtual machine) are required for many kinds of software,
including Tomcat, Jetty, Glassfish, Cassandra and Jenkins.
In this guide, you will install various versions of the Java Runtime Environment (JRE) and the Java
Developer Kit (JDK) using apt . 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:
One Ubuntu 18.04 server set up by following the the Ubuntu 18.04 initial server setup guide tutorial,
including a sudo non-root user and a firewall.
Installing the Default JRE/JDK
The easiest option for installing Java is to use the version packaged with Ubuntu. By default, Ubuntu
18.04 includes OpenJDK version 11, which is an open-source variant of the JRE and JDK.
To install this version, first update the package index:
sudo apt update
Next, check if Java is already installed:
java -version
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
Execute the following command to install the default Java Runtime Environment (JRE), which will
install the JRE from OpenJDK 11:
sudo apt install default-jre
The JRE will allow you to run almost all Java software.
Verify the installation with:
java -version
You’ll see the following output:
Output
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)
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:
javac -version
You’ll see the following output:
Output
javac 11.0.7
Next, let’s look at how to install Oracle’s official JDK and JRE.
Installing Oracle JDK 11
Oracle’s licensing agreement for Java doesn’t allow automatic installation through package managers.
To install the Oracle JDK, which is the official version distributed by Oracle, you must create an Oracle
account and manually download the JDK to add a new package repository for the version you’d like
to use. Then you can use apt to install it with help from a third party installation script.
The version of Oracle’s JDK you’ll need to download must match version of the installer script. To find
out which version you need, visit the oracle-java11-installer page.
Locate the package for Bionic, as shown in the following figure:
In this image, the version of the script is 11.0.7. In this case, you’ll need Oracle JDK 11.0.7. You don’t
need to download anything from this page; you’ll download the installation script
through apt shortly.
Then visit the Downloads page and locate the version that matches the one you need.
Click the JDK Download button and you’ll be taken to a screen that shows the versions available.
Click the .[Link] package for Linux.
You’ll be presented with a screen asking you to accept the Oracle license agreement. Select the
checkbox to accept the license agreement and press the Download button. Your download will
begin. You may need to log in to your Oracle account one more time before the download starts.
Once the file has downloaded, you’ll need to transfer it to your server. On your local machine, upload
the file to your server. On macOS, Linux, or Windows using the Windows Subsystem for Linux, use
the scp command to transfer the file to the home directory of your sammy user. The following
command assumes you’ve saved the Oracle JDK file to your local machine’s Downloads folder:
scp Downloads/jdk-11.0.7_linux-x64_bin.[Link] sammy@your_server_ip:~
Once the file upload has completed, return to your server and add the third-party repository that will
help you install Oracle’s Java.
Install the software-properties-common package, which adds the add-apt-repository command
to your system:
sudo apt install software-properties-common
Next, import the signing key used to verify the software you’re about to install:
sudo apt-key adv --keyserver [Link] --recv-keys EA8CACC073C3DB2A
You’ll see this output:
Output
gpg: key EA8CACC073C3DB2A: public key "Launchpad PPA for Linux Uprising" imported
gpg: Total number processed: 1
gpg: imported: 1
Then use the add-apt-repository command to add the repo to your list of package sources:
sudo add-apt-repository ppa:linuxuprising/java
You’ll see this message:
Output
Oracle Java 11 (LTS) and 12 installer for Ubuntu, Linux Mint and Debian.
Java binaries are not hosted in this PPA due to licensing. The packages in this PPA download
and install Oracle Java 11, so a working Internet connection is required.
The packages in this PPA are based on the WebUpd8 Oracle Java PPA packages:
[Link]
Created for users of [Link]
Installation instructions (with some tips), feedback, suggestions, bug reports etc.:
. . .
Press [ENTER] to continue or ctrl-c to cancel adding it
Press ENTER to continue the installation. You may see a message about no valid OpenPGP data
found, but you can safely ignore this.
Update your package list to make the new software available for installation:
sudo apt update
The installer will look for the Oracle JDK you downloaded in /var/cache/oracle-jdk11-installer-
local. Create this directory and move the Oracle JDK archive there:
sudo mkdir -p /var/cache/oracle-jdk11-installer-local/
sudo cp jdk-11.0.7_linux-x64_bin.[Link] /var/cache/oracle-jdk11-installer-local/
Finally, install the package:
sudo apt install oracle-java11-installer-local
The installer will first ask you to accept the Oracle license agreement. Accept the agreement, then the
installer will extract the Java package and install it.
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 update-alternatives command.
sudo update-alternatives --config java
This is what the output would look like if you’ve installed both versions of Java in this tutorial:
Output
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
* 2 /usr/lib/jvm/java-11-oracle/bin/java 1091 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 ( javac):
sudo update-alternatives --config javac
Other commands for which this command can be run include, but are not limited
to: keytool, javadoc and jarsigner.
Setting the JAVA_HOME Environment Variable
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 update-
alternatives command:
sudo update-alternatives --config java
This command shows each installation of Java along with its installation path:
Output
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
* 2 /usr/lib/jvm/java-11-oracle/bin/java 1091 manual mode
Press <enter> to keep the current choice[*], or type selection number:
In this case the installation paths are as follows:
1. OpenJDK 11 is located at /usr/lib/jvm/java-11-openjdk-amd64/bin/java.
2. Oracle Java is located at /usr/lib/jvm/java-11-oracle/jre/bin/java.
Copy the path from your preferred installation. Then open /etc/environment using 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, but do not include the /bin portion of the path:
/etc/environment
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
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:
source /etc/environment
Verify that the environment variable is set:
echo $JAVA_HOME
You’ll see the path you just set:
Output
/usr/lib/jvm/java-11-openjdk-amd64
Other users will need to execute the command source /etc/environment or log out and log back in
to apply this setting.
Conclusion
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.
================================================================================================
How to Download and Install Oracle JAVA 8 on
Ubuntu 18.04/16.04 LTS
Updated: June 5, 2020 by Sivasai Sagar
In this article, We are going to perform How to Download and Install Oracle JAVA 8 on Ubuntu
18.04/16.04 LTS Manually.
Table of Contents
Introduction
Java is a set of software and specifications developed at Sun Microsystems. There are two tyes of
Java Platforms are JDK (Java Development Kit) and JRE (Java Runtime Environment). Both are
helpful for deploying applications on servers and debugging, JVM monitoring,developing.
Java 8 Features:
Java 8 provides following features,
ForEach() method
Functional interfaces
Base64 Encode Decode
Parallel array sorting
Nashorn JavaScript Engine,
Parallel Array Sorting
Type and Repating Annotations
[Link] and [Link] Packages
To know more detailed features go through this link.
Prerequisites
Ubuntu Server 18.04/16.04 LTS
SSH access with sudo privileges
To check Ubuntu version:
$ uname -a
OR
$ cat /etc/os-release
Output:
cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="[Link]
SUPPORT_URL="[Link]
BUG_REPORT_URL="[Link]
PRIVACY_POLICY_URL="[Link]
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
Follow the below steps to Install Oracle Java 8 on Ubuntu Manually using command line.
Step 1: Download Oracle Java 8
Generally Oracle will not allow to download directly without accepting their licences. We have to
create one account in Oracle java website by your personal or official mail. After accepting licence
download the application from browser to local machine.
This link takes you to the Oracle home website Oracel Java SRE.
Once you opened above link goto “JAVA SE Development Kit 8u241” section, download “jdk-
[Link]” setup for Ubuntu click on “Accept License Agreement” Check Box.
After downloading into local machine, using SCP/SFTP/FTP transfer the file from local machine to
Ubuntu server.
Step 2: Copy downloaded Setup and Extract
Create a directory /opt/jdk
$ sudo mkdir -p /opt/jdk
Copy the tar file from the directory copied from local machine to server to /opt/jdk folder and
execute below command:
$ sudo cp -rf /home/sivasai/[Link] /opt/jdk/
$ cd /opt/jdk/
$ sudo tar -zxf [Link]
Now unarchived the file and check the content by long-list:
# ls
Step 3: Install Oracle Java 8 on ubuntu with Alternatives
Use update-alternatives command to configure java on your system
$ sudo update-alternatives --install /usr/bin/java java
/opt/jdk/jdk1.8.0_251/bin/java 100
After executing above command it shows below output:
Output:
update-alternatives: using /opt/jdk/jdk1.8.0_251/bin/java to provide /usr/bin/java
(java) in auto mode
Note : Its not particularly o/p if you have installed open jdk before
Step 4: Verify Update Alternatives
Enter below command shows output:
$ sudo update-alternatives --display java
Output:
$ sudo update-alternatives --display java
java - manual mode
link best version is /usr/lib/jvm/java-13-oracle/bin/java
link currently points to /opt/jdk/jdk-13.0.2/bin/java
link java is /usr/bin/java
slave [Link] is /usr/share/man/man1/[Link]
/opt/jdk/jdk-12.0.2/bin/java - priority
/opt/jdk/jdk-13.0.2/bin/java - priority 1
/opt/jdk/jdk1.8.0_251/bin/java - priority 100
/usr/lib/jvm/java-13-oracle/bin/java - priority 1091
slave [Link]: /usr/lib/jvm/java-13-oracle/man/man1/[Link]
To change for alternative mode:
$ sudo update-alternatives --config java
It prompts for selecting by 0,1,2..so choose accordingly:
Output
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-13-oracle/bin/java 1091 auto mode
1 /opt/jdk/jdk-12.0.2/bin/java 2 manual mode
* 2 /opt/jdk/jdk-13.0.2/bin/java 1 manual mode
3 /opt/jdk/jdk1.8.0_251/bin/java 100 manual mode
4 /usr/lib/jvm/java-13-oracle/bin/java 1091 manual mode
Press <enter> to keep the current choice[*], or type selection number: 3
update-alternatives: using /opt/jdk/jdk1.8.0_251/bin/java to provide /usr/bin/java
(java) in manual mode
Step 5: Setting the JAVA_HOME and JRE_HOME
Environment Variables
To define the enviroment variable:
$ sudo nano /etc/environment
Paste the below variable on the file:
/etc/environment
JAVA_HOME=/opt/jdk/jdk1.8.0_251
JRE_HOME=/opt/jdk/jdk1.8.0_251/jre
To check variables defined:
$ source /etc/environment
$ echo $JAVA_HOME
Output:
/opt/jdk/jdk1.8.0_251
$ sudo apt-get update
Step 6: Verify Java Version
To check the java version:
$ java -version
Output:
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)
If you seeing output like above then we have successfully set up the Java 8 on Ubuntu.
Conclusion
In this article, We have downloaded Oracle Java 8 from official site, installed using command line,
configured JAVA_HOME and JRE_HOME, verified installed version.
==============================================================================================
The Ubuntu repositories contain thousands of deb packages which can be installed from
the Ubuntu Software Center or by using the apt command-line utility. Deb is the installation
package format used by all Debian based distributions, including Ubuntu. Some packages
are not available in the standard Ubuntu repositories but they can be easily installed by
enabling the appropriate source.
Generally, when the software vendor does not provide a repository, they will have a
download page from where you can download and install the deb package or download
and compile the software from sources.
Although not so often, some software may be distributed only as an RPM package. RPM
is a package format used by Red Hat and its derivatives such as CentOS. Luckily, there is
a tool called alien that allows us to install an RPM file on Ubuntu or to convert an RPM
package file into a Debian package file.
Before you Begin
This is not the recommended way to install software packages in Ubuntu. Whenever
possible, you should prefer installing software from the Ubuntu repositories.
Not all RPM packages can be installed on Ubuntu. Installing RPM packaged on Ubuntu
may lead to package dependency conflicts.
You should never use this method to replace or update important system packages, like
libc, systemd, or other services and libraries that are essential for the proper functioning
of your system. Doing this may lead to errors and system instability.
Install Alien
Alien is a tool that supports conversion between Red Hat rpm, Debian deb, Stampede slp,
Slackware tgz, and Solaris pkg file formats.
Before installing the alien package, make sure the Universe repository is enabled on your
system:
sudo add-apt-repository universe
Once the repository is enabled, update the packages index and install the alien package
with:
sudo apt update sudo apt install alien
The command above will also install the necessary build tools.
Converting and Installing an RPM package
To convert a package from RPM to DEB format, use the alien command followed by the
RPM package name:
sudo alien package_name.rpm
Depending on the package size, the conversion may take some time. In most cases, you
will see warning messages printed on your screen. If the package is successfully
converted, the output will indicate that the DEB package is generated:
package_name.deb generated
To install the deb package , you can either use the dpkg or apt utility:
sudo dpkg -i package_name.deb
sudo apt install ./package_name.deb
The package should now be installed, assuming it’s compatible with your system, and all
dependencies are met.
You’ll need to be logged in as a user with sudo access to be able to install packages on
your Ubuntu system.
Installing an RPM package directly
Instead of converting and then installing the package, you can use the -i option that
tells alien to install the RPM package directly.
sudo alien -i package_name.rpm
The command above will automatically generate and install the package and remove the
package file after it has been installed.
==================================================================================================