Skip to content

Welcome to the JAVA 2 course

This repository contains the documents that will be used during the course.

After each session, you will also be able to find a possible solution for the practical exercises.

Prerequisites

To follow this course, you will have to use some tools, like the Java framework and an IDE. You will find here up-to-date information about which tools are required, and which versions you should use.

Info

I will provide support for these tools, in these particular versions.

Mind your IDE

I will not provide support for other tools that you may use, especially IDEs, as they can differ quite a lot between each other.

Use the right Java version

I will also not provide support if you don't respect the version. Java, as any other language, has version numbers for a reason. Some functions are not available on older version of Java, some functions are deprecated on newer version. The same goes for libraries and tools. Use the right version

Quickest way on Windows

Just install Eclipse IDE for Java Developers v2023.12:

  • download the installer here for Windows x64
  • select Eclipse IDE for Java Developers
  • in the next screen, choose JRE 21.0.1 from https://download.eclipse.org as your Java 21+ VM and click Launch

More details

Java framework

Info

TL;DR: You will need at least Java 21 SDK. Prefer the embedded version that comes with your IDE, it will spare you some setup. If you install the latest version of Eclipse IDE for Java Developers, Java 21 JRE can be selected during the installation process. IntelliJ IDEA also provides its own included Java Runtime, just be sure to use Java 21. Otherwise, grab the latest JDK21 version on Oracle JDK website.

Java follows a strange versioning path:

  • Java has regular versions, and LTS (long term support) versions.
  • Every Java version introduces GA (Globally available) changes, that are ready for production, and Preview changes, that are, well, for preview...
  • for years, versions have come at a rather slow pace, up until Java 8. These versions were introducing a lot of new features. Preview in 1.X meant GA in 1.X+1
  • from Java 9 and upwards, the rhythm as accelerated quite a lot, and we are already at Java 21 in less than four years. These version do not introduce as many features as the former ones. Preview in 1.X tends to mean GA in next LTS.
  • Java LTS versions are Java 8, Java 11, Java 17 and Java 21.
  • Java is leaded by Oracle, but is an opensource product. Several Companies offer support on the opensource distribution, providing their own packaging. We can mention Oracle of course, but also RedHat and AWS (with Correto). All these distributions are commercially available (meaning not always free !). There are also several flavors of opensource distributions, the most known being called OpenJDK, which is the Java community-based build, and Eclipse Temurin which is the one bundled with Eclipse IDE.

Do not use Oracle Java website

Do not use the Oracle Java website as a download base, as it advocates for installing Java 8, which is more than obsolete...

For this course, we will focus on three things:

  • Java LTS version, because that is the one you should use in the business context
  • GA functionalities, because these are the one that are supported by the LTS support contract, and consequently the ones you will use in a serious production environment.
  • HotSpot Virtual Machine, as it is the closer to what you will find in real production environments

As we are not tied to commercial support in the context of this course, we can use either the Oracle distributions or one of the numerous non-commercial distributions.

Info

If you have understood all the above, you know that we will use Java 21, and the HotSpot VM, using either the Oracle distribution, or the one embedded in your IDE. Download the Oracle version there for your favorite OS id needed.

Integrated Development Environment

Info

TL;DR: You will also need a Java IDE. Support for Eclipse will be provided during the course, prefer this version: Eclipse 2023-12 for Win64 platforms. Other platforms builds can be found here.

As every other language, Java is best edited using a suitable IDE. There are several IDE that you can find:

  • Eclipse, OpenSource, maintained by the Eclipse Foundation, is both free and powerful. This is the one I will support in the course.
  • IntelliJ Idea, commercial, maintained by JetBrains, is powerful and appealing, free for basic use, but advanced features require a license. It is on many points more powerful than Eclipse, but at a price. Though I won't provide support for it, you are more than welcome to use it if you prefer it over Eclipse.

Next to these two IDE, you can also find :

  • Visual Studio Code, Opensource, maintained by Microsoft. It is a swiss army knife of code edition, can do Java through the use of the RedHat Java Plugin, and can be tailored to your needs. It is far less integrated than Eclipse or Idea, and a little more difficult to configure. I will not provide support to this one, as every plugin that you use can break the whole thing...
  • Netbeans, OpenSource, Maintained by Apache Software Foundation, is yet another editor, less complete feature wise than the others, it requires also less resources to run. It provides great support for Swing application development, but lacks many modern features integrated in Eclipse & Idea. I will not provide support on this one, as it is too limited to handle maven projects correctly

Warning

Do yourself a favor, and uninstall NetBeans...

There are other commercial IDE that you can encounter in your Java learning path, just keep in mind that whatever the IDE you choose, you should learn how to use it extensively to be as efficient as possible.

Some Eclipse Shortcuts that will be handy

  • Ctrl+O outline to navigate through your source
  • Alt+Left → or Right ➝ to navigate between edition markers
  • Ctrl+Shift+Up ↑ or Down ↓ to navigate between members (methods and attributes)
  • F12 to focus on the editor
  • Ctrl+Page Up or Page Down to cycle between open editors
  • Ctrl+E to bring up the menu of open editors (Ctrl+F6 does a similar job)
  • Alt+Shift+N create menu
  • Alt+Shift+S source menu
  • Alt+Shift+T refactor menu
  • Alt+Shift+X execute menu

Source manipulation

  • Alt+Up or Down to move blocks of text around
  • Ctrl+D delete line
  • Ctrl+Shift+F format source file
  • Ctrl+Shift+C comment selection
  • Ctrl+Shift+O organize imports
  • Alt+Shift+J generate Javadoc

  • Ctrl+1 (Ctrl+Shift+& for Azerty keyboards) quick fix menu

... and the one and only...

  • Ctrl+Space autocomplete