Skip to content
A guide of modern Java (Java 17)
Jupyter Notebook Java Dockerfile
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.settings initial commit Dec 27, 2019
build remove the header (texts followed by blank lines) Jan 24, 2020
docker update to use resources from the docker folder Jan 11, 2020
guide polish Feb 1, 2020
jupyter polish Feb 1, 2020
.classpath initial commit Dec 27, 2019
.gitignore Initial commit Dec 27, 2019
.project initial commit Dec 27, 2019
Dockerfile simplify the Dockerfile Jan 11, 2020
LICENSE Initial commit Dec 27, 2019
README.md update README Feb 4, 2020
build.property update build.property to match the current configuration Jan 17, 2020
chapter00-genesis.jsh change examples to be more independent Jan 6, 2020
chapter01-basic_types.jsh simplify chapter 01 Jan 14, 2020
chapter02-methods.jsh editing Jan 6, 2020
chapter03-jshell_vs_java.jsh rename most of the chapters (again) Jan 2, 2020
chapter04-numbers.jsh NaN works if stored in a record component Jan 14, 2020
chapter05-control_flow.jsh add more meat Jan 11, 2020
chapter07-interface.jsh rework a little bit the chapter Jan 11, 2020
chapter08-lambda.jsh add more prints Jan 11, 2020
chapter09-list_and_map.jsh revisit Jan 11, 2020
chapter10-string_formatting.jsh polish Jan 11, 2020
chapter11-class_and_encapsulation.jsh rename chapter 11 Feb 1, 2020
chapter12-equals_hashCode_toString.jsh simplify end of chapter 12 Feb 1, 2020
chapter13-contract.jsh rename most of the chapters (again) Jan 2, 2020
chapter13-modifiable_vs_mutable.jsh Fix typos in chapter 13 Jan 30, 2020
chapter14-null_and_optional.jsh improvements Jan 11, 2020
chapter15-inheritance.jsh make examples compiles, reformat a little Jan 12, 2020
chapter16-exception.jsh add wrapper types and change interface a bit Dec 30, 2019
chapter17-enum.jsh add a section about EnumMap/EnumSet Jan 3, 2020
chapter18-nested_classes.jsh rename internal_class to nested Jan 11, 2020
chapter20-generics.jsh add more prints Jan 9, 2020
chapter21-wrapper.jsh fix typos Dec 30, 2019
chapter22-variance.jsh add more prints Jan 9, 2020
chapter23-limitation_of_generics.jsh remove the header (texts followed by blank lines) Jan 24, 2020
chapter25-stream.jsh polish Feb 1, 2020
chapter26-collector.jsh add chapter on streams Feb 1, 2020
chapter30-data_structure.jsh rename most of the chapters (again) Jan 2, 2020
chapter31-sort.jsh add numbers and string formatting and re-suffle things Dec 30, 2019

README.md

java-guide

A guide to modern Java (Java 17)

This guide is about learning Java from scratch if you know a bit of C or JavaScript.

This is a Work in progress, it should be ready when the next LTS of Java (Java 17) will be released. All the codes run with Java 14 with the preview features enabled.

Note: if you are looking to only what's new in Java 14 I have set of slides for that.

Content

  1. genesis.md
  2. basic_types.md
  3. methods.md
  4. jshell_vs_java.md
  5. numbers.md
  6. control_flow.md
  7. interface.md
  8. lambda.md
  9. list_and_map.md
  10. string_formatting.md
  11. class_and_encapsulation.md
  12. equals_hashCode_toString.md
  13. contract.md
  14. modifiable_vs_mutable.md
  15. null_and_optional.md
  16. inheritance.md
  17. exception.md
  18. enum.md
  19. nested_classes.md
  20. array.md
  21. implementing_interface.md
  22. generics.md
  23. wrapper.md
  24. variance.md
  25. limitation_of_generics.md
  26. stream.md
  27. collector.md
  28. data_structure.md
  29. sort.md

Using Java Shell (jshell)

Each chapter comes with executable examples that you can run using jshell.

To get the examples, just clone this repository

  git clone http://github.com/forax/java-guide

Then run jshell (at least Java 14 version)

   jshell --enable-preview

Then you can copy paste the examples inside jshell and see by yourself.

To quit use '/exit', to enable verbose error messages '/set feedback verbose', otherwise to get the help type '/help'

Using Jupyter notebook

on the cloud

You can run it directly in your browser Binder

or using docker

You need to have docker already installed, then

  • get the docker image from dockerhub
      docker pull forax/java-guide
    
  • run the docker image in a container
      docker run -p 8888:8888 forax/java-guide
    
  • open your browser using the tokenId printed on the console
      firefox http://localhost:8888/?token=tokenId
    

or install everything on your laptop

You need to have python3 and Java 14 already installed, then

  • clone this repository
      git clone http://github.com/forax/java-guide
      cd java-guide
    
  • install jupyter
      pip install notebook
    
  • install the ijava 1.3.0 kernel (from Spencer Park)
    wget https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip
    python3 install.py --sys-prefix
    
  • patch it with the repository file kernel.json list all kernels to see if the java kernel is installed
    jupyter kernelspec list
    
    then copy the file kernel.json from the folder docker to the java kernel directory
    cp docker/kernel.json /path/to/jupyter/kernels/java
    
  • set the env compiler option enabling the preview features
    export IJAVA_COMPILER_OPTS="--enable-preview -source 14"
    
  • run the notebook
    cd jupyter
    jupyter notebook
    

Build markdown and jupyter files from jshell files

The markdown files (.md) and the jupyter files (.ipynb) are derived/generated from the jshell files using a small Java script.

Using java 14

  java --enable-preview build/build.java
You can’t perform that action at this time.