Archives For java

Oracle announced Java 18 a few days ago. Here’s how to install the programming language in Ubuntu Linux.

What’s New in Java 18:

  • New Oracle Cloud Infrastructure (OCI) native service to help manage Java runtimes and applications on-premises or on any cloud.
  • Sets UTF-8 as the default charset of the standard Java APIs
  • A command-line tool and API to start a minimal web server that serves static files only.
  • Reimplement core reflection with method handles
  • Internet-Address Resolution SPI.
  • JEP Code Snippets in Java API Documentation.
  • Vector API (Third Incubator)
  • Foreign Function and Memory API (Second Incubator)
  • Pattern Matching for Switch (Second Preview)

Install JDK 18 in Ubuntu:

This Ubuntu PPA maintains installer script for automatically installing Java. It however does not update for the new Java 18 release.

So here’s the step by step guide shows how to install the official deb and set as default manually.

1. Download Java package

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

It’s a 64-bit .deb package for modern PC and laptops.

2. Install the .deb package

Next, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run the command below to install the package you just downloaded:

cd ~/Downloads && sudo apt install ./jdk-18_linux-x64_bin.deb

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

3. Set JDK 18 as default:

It installs the language files into ‘/usr/lib/jvm/jdk-18/‘ 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-18/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-18/bin/javac 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-18/bin/jar 1

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

b.) Next, run the commands below one by one, and type number to select Java JDK 18 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:

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

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

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

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

then add following lines:

export J2SDKDIR=/usr/lib/jvm/jdk-18
export J2REDIR=/usr/lib/jvm/jdk-18
export PATH=$PATH:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin
export JAVA_HOME=/usr/lib/jvm/jdk-18
export DERBY_HOME=/usr/lib/jvm/jdk-18/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-18
setenv J2REDIR /usr/lib/jvm/jdk-18
setenv PATH ${PATH}:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin
setenv JAVA_HOME /usr/lib/jvm/jdk-18
setenv DERBY_HOME /usr/lib/jvm/jdk-18/db

Finally, change the permissions via command, and it should take place at the next boot.

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

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.

The first bug-fix release of IntelliJ IDEA 2018.1 was released a few days ago with several important and critical bug-fixes.

IntelliJ IDEA 2018.1.1 includes following fixes:

  • An important fix that restores the automatic check for updates.
  • The keystrokes aren’t lost during freezing anymore
  • Clicking the Replace all option from the Replace in path dialog doesn’t cause the IDE to freeze
  • Issue with broken JPS that inhibits all non-gradle Android builds
  • Facet settings stored externally are now loaded by the build process
  • support for annotationProcessorPaths option in the maven-compiler-plugin 3.5 for external dependencies.
  • Performance for scrolling huge text file on 4K monitors was improved
  • The issue with AWT popups, which were above other process windows after alt-tab, was fixed

Install IntelliJ IDEA 2018.1.1 in Ubuntu:

Jetbrains offers official snap packages for Ubuntu Linux users. You can install it in Ubuntu 16.04, Ubuntu 17.10, Ubuntu 18.04 via following steps.

1. (Ubuntu 16.04 only) For those who never installed a snap package, open terminal (Ctrl+Alt+T) and run command to install snapd daemon:

sudo apt-get install snapd snapd-xdg-open

No visual feedback while typing your password due to security reason.

2. Then you can search for and install IDEA via Ubuntu Software:

Or run command in terminal instead to install the IDE:

snap install intellij-idea-community --classic

For the ultimate edition, replace intellij-idea-community with intellij-idea-ultimate in the code.