Archives For java

Oracle Java JDK 19 is out! Here are the new features and how to install instructions for Ubuntu users.

First, for Linux users the release now ported to support the RV64GV configuration of RISC-V, a general-purpose 64-bit ISA.

The release also introduced record patterns to deconstruct record values. Record patterns and type patterns can be nested to enable a powerful, declarative, and composable form of data navigation and processing. Though it’s a preview feature so far.

There are also 2 other preview features: a foreign function & memory API can interoperate with code and data outside of the Java runtime; a lightweight virtual threads that dramatically reduce the effort of writing, maintaining, and observing high-throughput concurrent applications; pattern matching for switch expressions and statements.

JDK 19 also introduced an API to express vector computations that reliably compile at runtime to optimal vector instructions, and an API for structured concurrency.

Other changes include:

  • New system properties for System.out and System.err.
  • upgrade Unicode support to 14.0
  • HTTPS channel binding support for Java GSS/Kerberos.
  • Support for PAC-RET protection on Linux/AArch64
  • Add a -providerPath option to jarsigner
  • New options for ktab to provide Non-Default salt
  • As well, there are removed and deprecated APIs and features. See release note details.

How to Install Java JDK 19 in Ubuntu Linux:

Oracle website provides the 64-bit DEB/RPM packages for Debian, Ubuntu, Fedora based systems. Just go download the package for your system from the link below:

In recent Linux systems, you can simply double-click on the package to install via system Software App. To set the Java home variable and use JDK 19 as default, see this step by step how to tutorial.

This simple tutorial shows how to install the latest Oracle Java (JDK 21 so far) in Ubuntu Linux via the official binary package.

There used to be unofficial Ubuntu PPA to automate the process of installing Java JDK and setup the environment, however, discontinued. So, here’s the tutorial to manually install the Java package and set as default.

Install JDK 21 in Ubuntu:

Press Ctrl+Alt+T on keyboard to open a terminal window and follow the steps below one by one.

1. Download Java package

Firstly, go to oracle website and select download the .deb package:

It’s the 64-bit .deb package for modern PC and laptops, or tarball for ARM cpu architecture.

2. Install the .deb package

Once you downloaded the package, open terminal (Ctrl+Alt+T) and run the command below to install the deb package:

sudo apt install ~/Downloads/jdk-21_linux-x64_bin.deb

Here you may also double-click the .deb in file manager to install it via Ubuntu Software App.

For the ARM package (for Raspberry Pi, Apple M1/2, etc), run command to create ‘/usr/lib/jvm’ directory in case it does not exist:

sudo mkdir -p /usr/lib/jvm

Then, extract the tarball to that directory via:

sudo tar -zxf ~/Downloads/jdk-21_linux-aarch64_bin.tar.gz -C /usr/lib/jvm/

3. Set JDK 21 as default (for ARM only):

UPDATE: The .deb package now automatically set Java 21 as default! So, you ONLY need to follow the steps below for the ARM package.

It installs the files into ‘/usr/lib/jvm/jdk-21/‘ directory. To set it as default, do the following 2 steps one by one.

a.) Create symbolic links for the executable files:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-21/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-21/bin/javac 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-21/bin/jar 1

Similarly, add links for other executable files (e.g., jarsigner, jlink, javadoc) as you need.

b.) Next, run the commands below one by one, and type number to select Java JDK 20 as default.

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar

When done, verify by running command in terminal:

java -version
javac -version

4. Set JAVA_HOME (for ARM only):

As well, you only need to do this for ARM package. If installed the .deb version, just verify JAVA HOME via the bottom command.

Option 1.) Set JAVA_HOME for current command console, that will work until you close it:

export JAVA_HOME=/usr/lib/jvm/jdk-21
setenv JAVA_HOME=/usr/lib/jvm/jdk-21

Option 2.) To make it permanent, create and edit config file via command:

sudo gedit /etc/profile.d/

Depends on your desktop environment, you may replace gedit with mousepad for XFCE, xed for Linux Mint, pluma for MATE, kate for KDE Plasma, gnome-text-editor for Ubuntu 23.04+.

then add following lines:

export J2SDKDIR=/usr/lib/jvm/jdk-21
export J2REDIR=/usr/lib/jvm/jdk-21
export PATH=$PATH:/usr/lib/jvm/jdk-21/bin:/usr/lib/jvm/jdk-21/db/bin
export JAVA_HOME=/usr/lib/jvm/jdk-21
export DERBY_HOME=/usr/lib/jvm/jdk-21/db

And create anther one for C shell:

sudo gedit /etc/profile.d/jdk.csh

add following lines and save it:

setenv J2SDKDIR /usr/lib/jvm/jdk-21
setenv J2REDIR /usr/lib/jvm/jdk-21
setenv PATH ${PATH}:/usr/lib/jvm/jdk-21/bin:/usr/lib/jvm/jdk-21/db/bin
setenv JAVA_HOME /usr/lib/jvm/jdk-21
setenv DERBY_HOME /usr/lib/jvm/jdk-21/db

Finally, change the permissions via command, and it should take place next time you log in.

sudo chmod +x /etc/profile.d/jdk.csh /etc/profile.d/

To verify JAVA HOME, run the command below in terminal at next login:

java -XshowSettings:properties -version

Uninstall Java JDK 21

To uninstall the Java package, open terminal (Ctrl+Alt+T) and run command:

sudo apt remove --autoremove jdk-21

For the ARM version, simply remove all the installed files, by running the commands below one by one:

  • Remove the alternative links:
    sudo update-alternatives --remove java /usr/lib/jvm/jdk-21/bin/java
    sudo update-alternatives --remove javac /usr/lib/jvm/jdk-21/bin/javac
    sudo update-alternatives --remove jar /usr/lib/jvm/jdk-21/bin/jar
  • Remove JDK installation files:
    sudo rm -R /usr/lib/jvm/jdk-21
  • And remove JAVA HOME config files:
    sudo rm /etc/profile.d/
    sudo rm /etc/profile.d/jdk.csh

Oracle announced the release of Java 17 as the new Long-Term Support (LTS) release.

Java 17 LTS comes with thousands of performance, stability, and security updates, as well as 14 JEPs (JDK Enhancement Proposals). And Oracle will provide 8-year support for the release with security, performance, and bug-fix updates until 2029.

According to the release note, the next LTS will be Java 21 planned for September 2023, which changes the LTS release circle for every three years to two years.

What’s New in Oracle Java 17:

JDK 17 includes new language enhancements, updates to the libraries, support for new Apple computers, removals and deprecations of legacy features, and work to ensure Java code written today will continue working without change in future JDK versions. It also offers a language feature preview and incubating APIs to gather feedback from the Java community.

Updates in the release include:

  • Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them.
  • Restore Always-Strict Floating-Point Semantics
  • New interface types and implementations for Pseudo-Random Number Generators (PRNGs), including jumpable PRNGs and an additional class of splittable PRNG algorithms (LXM).
  • Implement a Java 2D pipeline for macOS using the Apple Metal API.
  • New Arm 64-based Apple Silicon computers support.
  • Deprecate the Applet API for removal
  • Remove the Remote Method Invocation (RMI) Activation mechanism
  • Remove the Experimental AOT and JIT Compiler
  • Deprecate the Security Manager for removal
  • Strongly encapsulate all internal elements of the JDK, except for critical internal APIs such as sun.misc.Unsafe.
  • Pattern matching for switch expressions and statements, along with extensions to the language of patterns.
  • Improves Foreign Function and Memory API and Vector API.

How to Install Oracle Java 17 in Ubuntu:

Thanks to the “Linux Uprising” team ppa, an installer script has been created to automatically downloads and installs Oracle JDK 17 package, and sets Java 17 as the default Java version (setting JAVA_HOME, etc.) on 64-bit PC and arm64 devices, e.g., Rasperry Pi and Microsoft HoloLens 2.

1.) Firstly, open terminal either from system start menu or by pressing Ctrl+Alt+T on keyboard. When it opens, run command to add the PPA:

sudo add-apt-repository ppa:linuxuprising/java

Type user password when it asks (no asterisk feedback) and hit Enter to continue.

2.) Refresh system package cache. The PPA provides packages for Ubuntu 18.04, Ubuntu 20.04, Ubuntu 21.04, Ubuntu 21.10, as well as two old Ubuntu LTS (14.04 and 16.04). And old Ubuntu releases need to manually update system cache by running the command below in terminal:

sudo apt-get update

3.) Finally install the script package via command:

sudo apt-get install oracle-java17-installer

Once the script starts, it brings you to the screen for the license. Press Tab key on keyboard to select OK and hit Enter.

Then answer “Yes” via arrow keys and hit Enter to start downloading Java 17 package from oracle website.

Terminal will indicate the downloading and installing process for you. When everything’s done successfully, use java --version or javac --version command to verify the installation.

That’s all. Enjoy!

Jetbrains announced the release of IntelliJ IDEA 2018.2.3 a day ago with various bug-fixes and some improvements for v2018.2.

IntelliJ IDEA 2018.2.3 release highlights:

  • Ability to open HTML files in Edge using the Open in Browser action.
  • Fixed IntelliJ IDEA freezes.
  • Git: The built-in SSH doesn’t fail when Git protocol version 2 is enabled.
  • Fixed regressions in Mercurial support.
  • Docker: the IDE now validates Command line options and reports unknown options.
  • Docker: volume mounting now works on Windows using Linux containers.
  • Minor Gradle bug-fixes.

How to Insall the Latest IntelliJ IDEA in Ubuntu:

It’s quite easy to install the latest IDEA packages in Ubuntu since Jetbrains offers official snap (containerised software package) package in snappy store.

Simply open Ubuntu Software, search for and you’ll see IDEA ultimate and community packages available for install.

NOTE for Ubuntu 16.04 users who never installed a snap package, make sure snapd is installed by running command in terminal (Ctrl+Alt+T):

sudo apt install snapd snapd-xdg-open

Eclipse 4.8 Photon was released a week ago. You can now install it in Ubuntu 18.04, Ubuntu 17.10, Ubuntu 16.04 easily via snap package.

Eclipse Photon release highlights:

  • Full Eclipse IDE user experience for building, debugging, running and packaging Rust applications.
  • Expanded C# editing and debug capabilities, including syntax coloring, autocomplete suggestions, code diagnostics, and code navigation tools.
  • Java 9, Java 10 and JUnit 5 support.
  • Dark theme improvements in text colors, background color, popup dialogs, mark occurrences, and more.

How to Install Eclipse 4.8 Photon in Ubuntu:

The community has built the snap package of Eclipse Photon. It’s an universal Linux package format that bundles all its dependencies, and auto-updates itself once a new release is published.

The Eclipse 4.8.0 snap can by easily installed in Ubuntu Software:

Note that there are two versions of Eclipse in Ubuntu Software. Take a look at the version number before installing the package.

You can also install the snap by running command in terminal:

snap install --classic eclipse

In addition:

1. For Ubuntu 16.04 users never installed a snap package, make sure snapd daemon is installed via command:

sudo apt-get install snapd snapd-xdg-open

2. For Java environment, either install the OpenJDK via command:

sudo apt-get install default-jre

For Oracle Java 8 or Java 10, see this how to tutorial.