Java manual download page. Get the latest version of the Java Runtime Environment (JRE) for Windows, Mac, Solaris, and Linux. Java jdk 1 5 free download - Apple Java for OS X 10.5, Apple Mac OS Update 8.6, Apple Mac OS Update 9.0.4, and many more programs.
This topic includes the following sections:
System Requirements for Installing the JDK on macOS
The following are the system requirements for installing the JDK on macOS:
Any Intel-based computer running macOS.
Administrator privileges.
You cannot install Java for a single user. Installing the JDK on macOS is performed on a systemwide basis for all users. Administrator privileges are required to install the JDK on macOS.
Determining the Default JDK Version on macOS
When starting a Java application through the command line, the system uses the default JDK.
You can determine which version of the JDK is the default by entering java -version
in a Terminal window. If the installed version is 14 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 14
. For example:
To run a different version of Java, either specify the full path, or use the java_home
tool. For example:
$ /usr/libexec/java_home -v 14 --exec javac -version
Installing the JDK on macOS
- Download the JDK
.dmg
file,jdk-14.
interim.update.patch_osx-x64_bin.dmg
.Before the file can be downloaded, you must accept the license agreement.
- From either the browser Downloads window or from the file browser, double-click the
.dmg
file to start it.A Finder window appears that contains an icon of an open box and the name of the.pkg
file. - Double-click the
JDK 14.pkg
icon to start the installation application.The installation application displays the Introduction window. - Click Continue.
- Click Install. A window appears that displays the message: Installer is trying to install new software. Enter your password to allow this.
- Enter the Administrator user name and password and click Install Software.The software is installed and a confirmation window is displayed.
.dmg
file if you want to save disk space. Uninstalling the JDK on macOS
You must have Administrator privileges.Note:
Do not attempt to uninstall Java by removing the Java tools from /usr/bin
. This directory is part of the system software and any changes will be reset by Apple the next time that you perform an update of the OS.
- Go to
/Library/Java/JavaVirtualMachines
. - Remove the directory whose name matches the following format by executing the
rm
command as a root user or by using thesudo
tool:/Library/Java/JavaVirtualMachines/jdk-14.interim.update.patch.jdk
For example, to uninstall 14 Interim 0 Update 0 Patch 0:
$ rm -rf jdk-14.jdk
Installation FAQ on macOS Platform
This topic provides answers for the following frequently asked questions about installing JDK on macOS computers.
1. How do I find out which version of Java is the system default?
When you run a Java application from the command line, it uses the default JDK. If you do not develop Java applications, then you do not need to worry about this. See Determining the Default JDK Version on macOS.
2. How do I uninstall Java?
See Uninstalling the JDK on macOS.
3. After installing Java for macOS 2012-006, can I continue to use Apple's Java 6 alongside the macOS JDK for Java 14?
If you want to continue to develop with Java 6 using command-line, then you can modify the startup script for your favorite command environment. For bash, use this:
$ export JAVA_HOME=`/usr/libexec/java_home -v 14`
Some applications use /usr/bin/java
to call Java. After installing Java for macOS 2012-006, /usr/bin/java
will find the newest JDK installed, and will use that for all of the Java-related command-line tools in /usr/bin
. You may need to modify those applications to find Java 6, or contact the developer for a newer version of the application.
4. What happened to the Java Preferences app in Application Utilities?
The Java Preferences app was part of the Apple Java installation and is not used by Oracle Java. Therefore, macOS releases from Apple that do not include Apple Java will not include Java Preferences.
Java Development Kit (JDK), officially named 'Java Platform Standard Edition (Java SE)', which is freely available from Sun Microsystems (now part of Oracle), is needed for writing Java programs. The mother site for JDK (Java SE) is http://www.oracle.com/technetwork/java/index.html.
'JDK' or 'JRE'?
JRE (Java Runtime) is needed for running Java programs. JDK (Java Development Kit), which includes JRE plus the development tools (such as compiler and debugger), is need for writing as well as running Java programs. In other words, JRE is a subset of JDK. Since you are supposed to write Java Programs, you should install JDK, which includes JRE.
JDK Versions
The various JDK versions are:
- JDK Alpha and Beta (1995): Sun announced Java in September 23, 1995.
- JDK 1.0 (January 23, 1996): Originally called Oak (named after the oak tree outside James Gosling's office). Renamed to Java 1 in JDK 1.0.2.
- JDK 1.1 (February 19, 1997): Introduced AWT event model, inner class, JavaBean, JDBC, and RMI.
- J2SE 1.2 (JDK 1.2) (December 8, 1998): Re-branded as 'Java 2' and renamed JDK to J2SE (Java 2 Standard Edition). Also released J2EE (Java 2 Enterprise Edition) and J2ME (Java 2 Micro Edition). Included JFC (Java Foundation Classes - Swing, Accessibility API, Java 2D, Pluggable Look and Feel and Drag and Drop). Introduced Collection Framework and JIT compiler.
- J2SE 1.3 (JDK 1.3) (May 8, 2000): Introduced Hotspot JVM.
- J2SE 1.4 (JDK 1.4) (February 6, 2002): Introduced assert, non-blocking IO (nio), logging API, image IO, Java webstart, regular expression support.
- J2SE 5.0 (JDK 1.5) (September 30, 2004): Officially called 5.0 instead of 1.5. Introduced generics, autoboxing/unboxing, annotation, enum, varargs, for-each loop, static import.
- Java SE 6 (JDK 1.6) (December 11, 2006): Renamed J2SE to Java SE (Java Standard Edition).
- Java SE 7 (JDK 1.7) (July 28, 2011): First version after Oracle purchased Sun (called Oracle JDK).
- Java SE 8 (JDK 1.8) (March 18, 2014): included support for Lambda expressions, default and static methods in interfaces, improved collection, and JavaScript runtime.
- Java SE 9: Expected in July 2017.
1. How To Install JDK on Windows
Step 0: Un-Install Older Version(s) of JDK/JRE
I recommend that you install only the latest JDK. Although you can install multiple versions of JDK/JRE concurrently, it is messy.
If you have previously installed older version(s) of JDK/JRE, un-install ALL of them. Goto 'Control Panel' ⇒ 'Programs' ⇒ 'Programs and Features' ⇒ Un-install ALL programs begin with 'Java', such as 'Java SE Development Kit ...', 'Java SE Runtime ...', 'Java X Update ...', and etc.
Step 1: Download JDK
- Goto Java SE download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html.
- Under 'Java Platform, Standard Edition' ⇒ 'Java SE 8u{xx}', where {xx} is the latest update number ⇒ Click the 'JDK Download' button.
- Look for the latest 'Java SE Development Kit 8u{xx}' ⇒ Check 'Accept License Agreement'.
- Choose the JDK for your operating system, e.g., 'Windows x64' (for 64-bit Windows OS) or 'Windows x86' (for 32-bit Windows OS). You can check whether your Windows OS is 32-bit or 64-bit via 'Control Panel' ⇒ (Optional) System and Security ⇒ System ⇒ Under 'System Type'.
Step 2: Install JDK and JRE
Run the downloaded installer (e.g., 'jdk-8u{xx}-windows-x64.exe
'), which installs both the JDK and JRE. By default, the JDK will be installed in directory 'C:Program FilesJavajdk1.8.0_xx
', where xx
denotes the upgrade number; and JRE in 'C:Program FilesJavajre1.8.0_xx
'.
Install A Jdk For Mac
Accept the defaults and follow the screen instructions to install JDK and JRE.
Check the JDK installed directory by inspecting these folders using File Explorer. Take note of your JDK installed directory, in particular, the upgrade number, which you will need in the next step.
I shall refer to the JDK installed directory as <JAVA_HOME>
, hereafter, in this article.
Step 3: Include JDK's 'bin' Directory in the PATH
Windows Shell searches the current directory and the directories listed in the PATH
environment variable (system variable) for executable programs. JDK's programs (such as Java compiler javac.exe
and Java runtime java.exe
) reside in directory '<JAVA_HOME>bin
' (where <JAVA_HOME>
denotes the JDK installed directory). You need to include '<JAVA_HOME>bin
' in the PATH
to run the JDK programs.
To edit the PATH
environment variable in Windows 7/8/10:
- Launch 'Control Panel' ⇒ (Optional) System and Security ⇒ System ⇒ Click 'Advanced system settings' on the left pane.
- Switch to 'Advanced' tab ⇒ Push 'Environment Variables' button.
- Under 'System Variables' (the bottom pane), scroll down to select 'Path' ⇒ Click 'Edit...'.
- For Windows 10 (newer releases):
You shall see a TABLE listing all the existing PATH entries (if not, goto next step). Click 'New' ⇒ Enter the JDK's binary directory 'c:Program FilesJavajdk1.8.0_xxbin
' (Replacexx
with your installation number!!!) ⇒ Select 'Move Up' to move this entry all the way to the TOP.
Prior to Windows 10:
(CAUTION: Read this paragraph 3 times before doing this step! Don't push 'Apply' or 'OK' until you are 101% sure. There is no UNDO!!!)
(To be SAFE, copy the content of the 'Variable value' to Notepad before changing it!!!)
In 'Variable value' field, INSERT 'c:Program FilesJavajdk1.8.0_xxbin
' (Replacexx
with your installation number!!!)IN FRONT of all the existing directories, followed by a semi-colon (;
) which separates the JDK's binary directory from the rest of the existing directories. DO NOT DELETE any existing entries; otherwise, some existing applications may not run.
My Notes: Starting from JDK 1.8, the installation created a directory 'c:ProgramDataOracleJavajavapath
' and added to the PATH. It contains only JRE executables (java.exe
, javaw.exe
, javaws.exe
) but NOT the JDK executables (e.g., javac.exe
).
Step 4: Verify the JDK Installation
Launch a CMD shell via one of the following means:
- Click 'Search' button ⇒ Enter 'cmd' ⇒ Choose 'Command Prompt', or
- right-click 'Start' button ⇒ run... ⇒ enter 'cmd', or
- (Prior to Windows 10) click 'Start' button ⇒ All Programs ⇒ Accessories (or Windows System) ⇒ Command Prompt, or
- (Windows 10) click 'Start' button ⇒ Windows System ⇒ Command Prompt
Issue the following commands to verify your JDK installation:
- Issue '
path
' command to list the contents of thePATH
environment variable. Check to make sure that your<JAVA_HOME>bin
is listed in thePATH
.
Don't typeprompt>
, which denotes the command prompt!!! Key in the command (highlighted) only. - Issue the following commands to verify that JDK/JRE are properly installed and display their version:
Step 5: Write a Hello-World Java Program
- Create a directory to keep your works, e.g., '
d:myProject
', or 'c:myProject
', or any directory of your choice. 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. - Launch a programming text editor (such as TextPad, or NotePad++, or Sublime Text, or Atom). Begin with a new file and enter the following source code. Save the file as '
Hello.java
', under your work directory (e.g.,d:myProject
).
Step 6: Compile and Run the Hello-World Java Program
To compile the source code 'Hello.java
':
- Start a CMD Shell (Click the 'Start' button ⇒ 'run...' ⇒ Enter 'cmd').
- Set the Current Drive to the drive where you saved your source file '
Hello.java
'. For example, suppose that your source file is saved in drive 'd
', enter 'd:
' as follow: Don't enterprompt>
, which denotes the command prompt. - Set the Current Working Directory to the directory that you saved your source file via the
cd
(Change Directory) command. For example, suppose that your source file is saved in directory 'd:myProject
'. - Issue a
dir
(List Directory) command to confirm that your source file is present in the current directory. - Invoke the JDK compiler '
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. - The output of the compilation is a Java class called '
Hello.class
'. Issue adir
(List Directory) command again to check for the output.
To run the program, invoke the Java Runtime 'java
':
Everything that can possibly go wrong will go wrong: Read 'JDK Installation Common Errors'.
Step 7: (Optional) Download JDK API Documentation, Samples and Demos
The JDK download does not include the documentation, which needs to be downloaded separately. In the past, I always insist that my students should have a local copy of JDK API Documentation. But, today, you can easily access the online copy by googling 'JDK 8 Documentation'.
To install JDK API documentation:
- From the Java SE download page (@ http://www.oracle.com/technetwork/java/javase/downloads/index.html), under 'Additional Resources', look for 'Java SE 8 Documentation' ⇒ Download ⇒ Accept the license agreement ⇒ Download the zip-file (e.g., '
jdk-8u{xx}-apidocs.zip
' - about 85MB). - Unzip into the JDK installed directory
<JAVA_HOME>
. The documentation will be unzipped into '<JAVA_HOME>docs
'. Browse the JDK documentation by opening '<JAVA_HOME>docsindex.html
'.
You should also download the 'JDK 8 Samples and Demos' from the Java SE download site.
Step 8: (For Advanced Users Only) JDK's Source Code
Source code for JDK is provided and kept in '<JAVA_HOME>src.zip
'. I strongly recommend that you to go through some of the source files such as 'String.java
', 'Math.java
', and 'Integer.java
', under 'javalang
'.
1.1 Using TextPad for Java Programming (on Windows)
TextPad (@ www.textpad.com) is a lightweight programming text editor for writing toy Java programs. It can be configured to couple with the JDK, hence, bypassing the CMD shell.
From the TextPad editor, you can invoke the JDK compiler/runtime directly via 'Tools' menu ⇒ External Tools ⇒ 'Compile Java' or 'Run Java Application'. Take note of the keyboard shortcuts - Ctrl+1 for compile and Ctrl+2 for run.
If you cannot find these commands in the 'Tools' menu, goto 'Configure' ⇒ Preferences... ⇒ Tools ⇒ Add ⇒ JDK Commands.
TextPad Tips and Configuration
Check HERE!
1.2 Using NotePad++ for Java Programming (on Windows)
Notepad++ (@ http://notepad-plus-plus.org) is a free and open-source programming editor.
You can use NotePad++ to write your Java source code. But you need to use CMD shell to compile and run the Java program.
NotePad++ Customization and Tips
You can customize Notepad++ to compile and run Java programs with hot-keys. Read 'NotePad++'.
2. How to Install JDK on Mac OS
Step 1: Check if JDK has been Pre-Installed
In some Mac systems (earlier than Mac OS X 10.7 Lion), JDK has been pre-installed. To check if JDK has been installed, open a 'Terminal' (Search 'Terminal'; or Finder ⇒ Go ⇒ Utilities ⇒ Terminal) and issue this command:
- If a JDK version number is returned (e.g.,
JDK 1.x.x
), then JDK has already been installed. If the JDK version is prior to 1.7, proceed to Step 2 to install the latest JDK; otherwise, proceed to 'Step 3: Write a Hello-world Java program'. - If message 'command not found' appears, JDK is NOT installed. Proceed to the 'Step 2: Install JDK'.
- If message 'To open javac, you need a Java runtime' appears, select 'Install' and follow the instructions to install JDK. Then, proceed to 'Step 3: Write a Hello-world Java program'.
Step 2: Download JDK
- Goto Java SE download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html. Under 'Java Platform, Standard Edition' ⇒ 'Java SE 8u{xx}' ⇒ Click the 'JDK Download' button
- Check 'Accept License Agreement'
- Choose your operating platform, e.g., 'Mac OS X' (
jdk-8u{xx}-macosx-x64.dmg
). Download the installer.
Step 3: Install JDK/JRE
- Double-click the downloaded Disk Image (DMG) file. Follow the screen instructions to install JDK/JRE.
- Eject the DMG file.
- To verify your installation, open a 'Terminal' and issue these commands.
Step 3: Write a Hello-World Java Program
- Create a directory called '
myProject
' under your home directory (Launch 'Finder' ⇒ 'Go' ⇒ 'Home'; Select 'File' ⇒ 'New Folder' ⇒ 'myProject
').
In Mac OS, the home directory of the current login user is denoted as '~
'. Hence, this new directory is represented as '~/myProject
'. - Use a programming text editor (such as jEdit, gedit, Sublime Text, or Atom) to input the following source code and save as '
Hello.java
'under the directory '~/myProject
'.
[If you use Mac OS's default text editor 'TextEdit' (NOT recommended), you need to open a new file ⇒ choose 'Format' ⇒ 'Make Plain Text' ⇒ Enter the source code ⇒ Save as 'Hello.java
'.]
Step 4: Compile and Run the Hello-World Java Program
- To compile the source code '
Hello.java
', open a new 'Terminal' ('Go' ⇒ 'Utilities' ⇒ 'Terminal') and issue these commands (as illustrated): - To run the Hello-world, invoke the Java Runtime '
java
' as follows:
3. How to Install JDK on Ubuntu
There are several JDK implementations available for Linux, such as Oracle JDK, OpenJDK, Sun JDK, IBM JDK and GNU Java Compiler. We shall choose the Oracle JDK 8. Ubuntu chooses OpenJDK as its default JDK, which is not 100% compatible with Oracle JDK.
Step 0: Check if JDK has already been Installed
Open a Terminal and issue this command:
If a JDK version number (e.g., 'javac 1.x.x_xx
') appears, JDK has already been installed. You can skip the installation and goto step 2.
To remove OpenJDK, issue command:
Step 1: Download and Install JDK
- Goto JDK (Java SE) download site @ http://www.oracle.com/technetwork/java/javase/downloads/index.html. Under 'Java Platform, Standard Edition' ⇒ 'Java SE 8u{xx}' ⇒ Click 'JDK Download' ⇒ Under 'Java SE Development Kit 8u{xx}' ⇒ Accept License Agreement ⇒ Select 'Linux x86' (for 32-bit system) or 'Linux x64' (for 64-bit system) '
tar.gz
' package, e.g., 'jdk-8u{xx}-linux-i586.tar.gz
'. (To check your OS version, goto 'Settings' ⇒ 'Details'.)
The tarball will be downloaded in directory '~/Downloads
', by default. - We shall install JDK under '
/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/jdk1.8.0_{xx}
', where{xx}
is the upgrade number. - Inform the Ubuntu to use this JDK/JRE: The above steps set up symlinks
java
,javac
,javaws
at/usr/bin
(which is in the PATH), that link to/etc/alternatives
and then to JDK bin directory.
The 'alternatives' system aims to resolve the situation where several programs fulfilling the same function (e.g., different version of JDKs). It sets up symlinks thru/etc/alternatives
to refer to the actual programs to be used.
Alternatively, you can include the JDK's bin and JRE's bin into the PATH directly. - To verify the JDK installation, issue these commands:
- (Optional) To use Java under Firefox, you need to enable the so-called 'Java Plugin for web browser'. Then, create a symbolic link to your Mozilla plugins folder, (check your JDK folder)To verify the installation, restart your Firefox and issue URL '
about:plugins
'. Check for Java plugins with the correct version.
Starting from JDK 1.8, to run unsigned applets, you need to set security level to 'high' add the sites to the 'Exception List' (under the Java Control Panel ⇒ Security). To start the Java Control Panel:You need to restart Firefox after modifying the Exception List. - [Don't Do this step - It is taken care by 'alternative' in Step 3. Keep here to show you how to set PATH.]
Add JDK's binary directory ('bin
') to the 'PATH' by editing '/etc/profile
': Add these lines at the end of the file '/etc/profile
', replace '{xx}
' with the actual number:Rerun the configuration file by:
Step 2: Compile and Run a Hello-world Java Program
- File Explorer ⇒ Home ⇒ Create a new folder called '
myProject
' to keep our works. - Open 'Text Editor' (gedit). Enter the following source code and save as '
Hello.java
' under the '~/myProject
' directory created earlier. - To compile the Hello-world Java program, launch a Terminal and issue these commands:
- Run the Hello-world Java program:
4. First Java Program with Eclipse
- You need to first install Eclipse. Read 'How to Install Eclipse'.
- You can then proceed to write your first Java program. Read 'Writing your first Java Program with Eclipse'.
- Eclipse allow you to debug program graphically. Read 'Debugging program in Eclipse'.
5. First Java Program with NetBeans
- You need to first install NetBeans. Read 'How to Install NetBeans'.
- You can then proceed to write your first Java program. Read 'Writing your first Java program with NetBeans'.
- NetBeans allow you to debug program graphically. Read 'Debugging program in NetBeans'.
6. (Advanced) External JAR Files and Native Libraries
External Java packages (such as Servlet, MySQL Connector/J, JOGL, JUnit) are often distributed in JAR files (Java Archive - a single-file package of many Java classes), with possibly Native Libraries ('.lib
' and '.dll
' in Windows, or '.a
' and '.so
' in Linux/Mac).
External JAR Files ('.jar')
If external JAR files are not properly included:
- During the compilation, you will receive compilation error 'cannot find symbol' on classes belonging to the external packages.
- During execution, you will get a runtime error 'Could not find or load main class xxx' or '
NoClassDefFoundError
'.
To include external JAR files, you can either:
Java Jdk 8 Download Mac Os
- Copy all the JAR files of the external packages to the Java's Extension Directories.
- For Windows, the JDK extension directory is located at '
<JAVA_HOME>jrelibext
' (e.g., 'c:Program FilesJavajdk1.8.0_xxjrelibext
'). - For Mac, the JDK extension directories are '
/Library/Java/Extensions
' and '/System/Library/Java/Extensions
'. - For Ubuntu, the JDK extension directories are '
<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 viaSystem.out.println(System.getProperty('java.ext.dirs'))
. - For Windows, the JDK extension directory is located at '
- You can also include all the JAR files in the
CLASSPATH
environment variable.CLASSPATH
may contain directories (of Java classes) or JAR files (single-file archive of Java classes). If you set theCLASSPATH
, you must also include the current directory (denoted as '.
').- For Windows, set the
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 (;
). - For Linux and Mac OS: Edit
~/.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 (:
).
- For Windows, set the
- You can also set the
CLASSPATH
in thejavac
/java
command-line via the option-cp <paths>
(or-classpath <paths>
), for example,
External Native Libraries ('.lib', '.dll', '.a', '.so')
Some external package may provide static or shared native libraries in the form of '.lib
' (Windows' static library), '.dll
' (Windows' dynamically link library), '.a
' (Unix's static library), or '.so
' (Unix's shared library).
Native Libraries are to be kept in a directory accessible via JRE's Property 'java.library.path
', which normally but not necessarily includes all the directories in the PATH
environment variable.
Native libraries are not involved in the compilation. But if they are not properly included during runtime time, you will get a runtime error 'java.lang.UnsatisfiedLinkError: no xxx in java.library.path
'.
Jdk Download For Mac Os
To include external native libraries:
- Copy the native libraries into a system library directory, e.g.,
c:windowssystem32
(Windows),/usr/lib
or/usr/local/lib
(Linux or Mac OS). You can verify that the directory is included in Java's System Property 'java.library.path
', viaSystem.out.println(System.getProperty('java.library.path'))
. - You can also set the native library path via the
java
's command-line option-Djava.library.path=xxx
, for example,
Download Java Jdk 8 Mac Os Iso
Eclipse/NetBeans
Using an IDE can greatly simplifies inclusion of external packages. Read 'Eclipse How-To' or 'NetBeans How-To'.