assert
statement, non-blocking IO (nio
), logging API, image IO, Java webstart, regular expression (regex) support.module
) under project Jigsaw, the Java Shell (jshell
), and more.var
for type inference local variable (similar to JavaScript). Introduced time-based release versioning with 2 releases each year, in March and September, denoted as YY.M.
Removed native-header generation tool javah
.var
to lambda expression. Standardize HTTP client in java.net.http
. Support TLS 1.3. Clean up the JDK and the installation package (removed JavaFX, JavaEE, CORBA modules, deprecated Nashorn JavaScript engine).jdk-11.0.{x}_windows-x64_bin.exe
' - about 150MB).jdk-11.0.{x}_windows-x64_bin.exe
'), which installs both the JDK and JRE.C:Program FilesJavajdk-11.0.{x}
', where {x}
denotes the update number. Accept the defaults and follow the screen instructions to install JDK.'C:Program FilesJava'
to inspect the sub-directories. Take note of your JDK installed directory, in particular, the update number {x}
, which you will need in the next step.C:Program FilesJavajdk-11.0.1
', where {x}=1
.<JAVA_HOME>
, hereafter, in this article.CMD
) searches the current directory and the directories listed in the PATH
environment variable (or system variable) for executable programs. JDK's programs (such as Java compiler 'javac.exe
' and Java runtime 'java.exe
') reside in the sub-directory 'bin
' of the JDK installed directory. You need to include JDK's 'bin
' in the PATH
to run the JDK programs.PATH
environment variable in Windows 10:bin
' directory, i.e., 'c:Program FilesJavajdk-11.0.{x}bin
', where {x}
is your installation update number ⇒ Select 'Move Up' to move this entry all the way to the TOP.c:Program FilesJavajdk-11.0.{x}bin
' (where {x}
is your installation update number) IN FRONT of all the existing directories, followed by a semi-colon (;
) to separate the JDK's bin directory from the rest of the existing directories. DO NOT DELETE any existing entries; otherwise, some existing applications may not run. CMD
via one of the following means:path
' command to list the contents of the PATH
environment variable. Check to make sure that your JDK's 'bin
' is listed in the PATH
. d:myProject
' or 'c:myProject
'. Do NOT save your works in 'Desktop' or 'Documents' as they are hard to locate. The directory name shall not contain blank or special characters. Use meaningful but short name as it is easier to type.Hello.java
', under your work directory (e.g., d:myProject
). Hello.java
':Hello.java
'. d
', enter 'd:
' as follow: cd
(Change Directory) command. For example, suppose that your source file is saved in directory 'myProject
'.dir
(List Directory) command to confirm that your source file is present in the current directory. javac
' to compile the source code 'Hello.java
'. The compilation is successful if the command prompt returns. Otherwise, error messages would be shown. Correct the errors in your source file and re-compile. Check 'Common JDK Installation Errors', if you encounter problem compiling your program.Hello.class
'. Issue a dir
(List Directory) command again to check for the output. java
':jdk-11.0.{x}_doc-all.zip
' - about 50MB).<JAVA_HOME>
. The documentation will be unzipped into '<JAVA_HOME>docs
'. Browse the JDK documentation by opening '<JAVA_HOME>docsindex.html
'.<JAVA_HOME>libsrc.zip
' (or '<JAVA_HOME>src.zip
' prior to JDK 9). I strongly recommend that you to go through some of the source files such as 'String.java
', 'Math.java
', and 'Integer.java
', under 'javalang
'.JAVA_HOME
to be set to the JDK installed directory.JAVA_HOME
environment variable:c:Program FilesJavajdk-11.0.{x}
', where '{x}
is the update number. Use your 'File Explorer' to find this directory and take note of your update number {x}
.JAVA_HOME
is already set. Start a CMD and issue: If you get a message 'Environment variable JAVA_HOME
not defined', proceed to the next step. JAVA_HOME=C:Program FilesJavajdk-11.0.{x}
', verify that it is set correctly to your JDK directory. If not, proceed to the next step.JAVA_HOME
in Windows 10: JAVA_HOME
' and 'Edit' if it is already set) ⇒ In 'Variable Name', enter 'JAVA_HOME
' ⇒ In 'Variable Value', enter your JDK installed directory you noted in Step 1. (In the latest Windows 10: you can push the 'Browse Directory' button and navigate to the JDK installed directory to avoid typo error.)JAVA_HOME
, PATH
) are NOT case-sensitive.JDK x.x.x
), then JDK has already been installed. If the JDK version is prior to 1.8, proceed to Step 2 to install the latest JDK; otherwise, proceed to 'Step 3: Write a Hello-world Java program'.jdk-11.0.{x}_osx-x64_bin.dmg
- about 166MB).myProject
' under your home directory (Launch 'Finder' ⇒ 'Go' ⇒ 'Home'; Select 'File' ⇒ 'New Folder' ⇒ 'myProject
').~
'. Hence, this new directory can be referenced as '~/myProject
'.Hello.java
' under the directory '~/myProject
'.Hello.java
'.) Hello.java
', open a new 'Terminal' ('Go' ⇒ 'Utilities' ⇒ 'Terminal') and issue these commands (as illustrated): java
' as follows: javac x.x.x
') appears, JDK has already been installed. You can skip the installation and goto step 2.tar.gz
' package, (e.g., 'jdk-11.0.{x}-linux-x64_bin.tar.gz
' - 171MB).~/Downloads
', by default./usr/local/java
' (or Ubuntu's default JDK directory /usr/lib/jvm
; or /opt/java
). First, create a directory 'java
' under '/usr/local
'. Open a Terminal and issue these commands: Extract the downloaded package (Check your downloaded filename!) JDK shall be extracted in a folder '/usr/local/java/jdk-11.0.{x}
', where {x}
is the update number.java
, javac
, javaws
at /usr/bin
(which is in the PATH), that link to /etc/alternatives
and then to JDK bin directory./etc/alternatives
to refer to the actual programs to be used.bin
') to the 'PATH' by editing '/etc/profile
': Add these lines at the end of the file '/etc/profile
', replace '{x}
' with the actual number: Rerun the configuration file by: myProject
' to keep our works.Hello.java
' under the '~/myProject
' directory created earlier. Hello.java
' (see previous section).Hello.class
', if it exists.Hello.java
' in one command as follows: javac
to compile the program..class
file), and run.jmod
' files for Java modules. Need to revise this section for JDK 9..lib
' and '.dll
' in Windows, or '.a
' and '.so
' in Linux/Mac).NoClassDefFoundError
'.<JAVA_HOME>jrelibext
' (e.g., 'c:Program FilesJavajdk1.8.0_xxjrelibext
')./Library/Java/Extensions
' and '/System/Library/Java/Extensions
'.<JAVA_HOME>/jre/lib/ext
' (e.g., '/usr/user/java/jdk1.8.0_xx/jre/lib/ext
') and '/usr/java/packages/lib/ext
'.java.ext.dirs
'. You can print its contents via System.out.println(System.getProperty('java.ext.dirs'))
.CLASSPATH
environment variable. CLASSPATH
may contain directories (of Java classes) or JAR files (single-file archive of Java classes). If you set the CLASSPATH
, you must also include the current directory (denoted as '.
'). CLASSPATH
in Control Panel ⇒ System ⇒ Advanced system settings ⇒ Advanced ⇒ Environment Variables ⇒ System Variables ⇒ New ⇒ In 'Variable name', enter 'CLASSPATH
' ⇒ In 'Variable value', enter '.;path1xxx.jar;path2yyy.jar
', where the entries are separated by a semi-colon (;
).~/.profile
or ~/.bash_profile
(or /etc/profile
for system-wide setting) to include the following line at the end of the file: The entries are separated by colon (:
).CLASSPATH
in the javac
/java
command-line via the option -cp <paths>
(or -classpath <paths>
), for example, .lib
' (Windows' static LIBrary), '.dll
' (Windows' Dynamically Link Library), '.a
' (Unix's static (Archive) library), or '.so
' (Unix's Shared Object library).java.library.path
', which normally but not necessarily includes all the directories in the PATH
environment variable.java.lang.UnsatisfiedLinkError: no xxx in java.library.path
'. c:windowssystem32
(Windows), /usr/lib
or /usr/local/lib
(Mac OS X / Unix). You can verify that the directory is included in Java's System Property 'java.library.path
', via System.out.println(System.getProperty('java.library.path'))
.java
's command-line option -Djava.library.path=xxx
, for example,