Java manual download page. Get the latest version of the Java Runtime Environment (JRE) for Windows, Mac, Solaris, and Linux. Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with no-cost long-term support. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard.
Package Description
The essential tools for any Java developer, including a Java IDE, a CVS client, Git client, XML Editor, Mylyn, Maven integration and WindowBuilder
This package includes:
- Eclipse Git Team Provider
- Eclipse Java Development Tools
- Maven Integration for Eclipse
- Mylyn Task List
- Code Recommenders Tools for Java Developers
- WindowBuilder Core
- Eclipse XML Editors and Tools
- org.eclipse.cvs
- org.eclipse.egit
- org.eclipse.egit.import
- org.eclipse.egit.mylyn
- org.eclipse.epp.package.common.feature
- org.eclipse.equinox.p2.user.ui
- org.eclipse.help
- org.eclipse.jdt
- org.eclipse.jgit
- org.eclipse.m2e.feature
- org.eclipse.m2e.logback.feature
- org.eclipse.mylyn.bugzilla_feature
- org.eclipse.mylyn.context_feature
- org.eclipse.mylyn.cvs
- org.eclipse.mylyn_feature
- org.eclipse.mylyn.git
- org.eclipse.mylyn.hudson
- org.eclipse.mylyn.ide_feature
- org.eclipse.mylyn.java_feature
- org.eclipse.mylyn.wikitext_feature
- org.eclipse.platform
- org.eclipse.rcp
- org.eclipse.recommenders.rcp.feature
- org.eclipse.wb.core.feature
- org.eclipse.wb.core.ui.feature
- org.eclipse.wb.layout.group.feature
- org.eclipse.wb.swing.feature
- org.eclipse.wst.xml_ui.feature
Maintained by: Eclipse Mylyn Project
Windows 32-bit
Windows x86_64
macOS 32-bit
macOS x86_64
Linux 32-bit
Linux x86_64
Windows x86_64
macOS 32-bit
macOS x86_64
Linux 32-bit
Linux x86_64
Windows 32-bit: MD5 - SHA1 - SHA512
Windows 64-bit: MD5 - SHA1 - SHA512
Mac OS X (Cocoa) 32-bit: MD5 - SHA1 - SHA512
Mac OS X (Cocoa) 64-bit: MD5 - SHA1 - SHA512
Linux 32-bit: MD5 - SHA1 - SHA512
Linux 64-bit: MD5 - SHA1 - SHA512
Windows 64-bit: MD5 - SHA1 - SHA512
Mac OS X (Cocoa) 32-bit: MD5 - SHA1 - SHA512
Mac OS X (Cocoa) 64-bit: MD5 - SHA1 - SHA512
Linux 32-bit: MD5 - SHA1 - SHA512
Linux 64-bit: MD5 - SHA1 - SHA512
Bugzilla
Bug ID | Title | Status |
516739 | Add WindowBuilder to Java package again | NEW |
513809 | [wiring] HttpComponents wiring issue | NEW |
509799 | Symantec reports a Trojan SONAR.AM.C!g24 in eclipse | NEW |
508091 | Duplicate options in Eclipse.ini | NEW |
521514 | Add 'Eclipse News' RSS feed to Java Package | NEW |
522649 | News feed plugin not installed on upgrade installs | NEW |
536469 | Use png with transparent icon in the about dialog of Java EPP (and others if applicable) | NEW |
530698 | Using weka api | NEW |
526611 | win64 version missing | NEW |
498457 | FileNotFoundException : org.eclipse.ui_3.108.0.v20160518-1929.jar | NEW |
489296 | Improve out-of-box experience for non-english locales | NEW |
386806 | New Eclipse Icon not used by Eclipse 4.2 on Windows 7 | NEW |
374170 | bugs when updating software | NEW |
364551 | setup automated tests for Java EPP package | NEW |
414381 | Failed to load the JNI shared library 'C:ogramFilesJavajre6binclientjvm.dll' | NEW |
458646 | Problème démarrage Eclipse | NEW |
355002 | EPP packages need styling | NEW |
473585 | Help system broken after updating from Luna to Mars | NEW |
487713 | FileNotFoundException: introData.xml | NEW |
382232 | Add 'EGit Import' to EPP package with EGit | ASSIGNED |
487722 | Dead link for 'Remote Help': Topic not found | REOPENED |
Bugs listed in italics indicate the bug has been moved to another project.
Bug ID | Title | Status |
382804 | Ctrl+C, Ctrl+V shortcuts don't work while editing Android XML | RESOLVED |
492163 | Add Maven to java package | RESOLVED |
383193 | Taskbar icon doesn't show Android build progress | RESOLVED |
490044 | [Welcome] Adopt Solstice theme for Java package | RESOLVED |
386686 | the Mobile package should include the Mylyn Bugzilla connector | RESOLVED |
365594 | add code recommenders to java package | RESOLVED |
358692 | Eclipse java package crash in Ubuntu 11.0.4 | RESOLVED |
356126 | fix Mylyn repository URLs in EPP packages for Indigo | RESOLVED |
356349 | update Mylyn URLs for Juno | RESOLVED |
357020 | add Mylyn Hudson/Jenkins connector to Java package | RESOLVED |
357332 | Annotations not shown on overview ruler | RESOLVED |
389113 | Unable to Launch Eclipse after download and setup: 'The Eclipse executable launcher was unable to locate its companion shared library.' | RESOLVED |
406246 | zip compression error | RESOLVED |
468598 | Mars RC1 Mac packages are damaged | RESOLVED |
535504 | Open file feature broken in Photon RC2 EPP packages | RESOLVED |
474204 | Include Buildship as part of Java package | RESOLVED |
534617 | [Photon] [java] Add Tip of the Day to the Java Package | RESOLVED |
528429 | m2e to download sources by default | RESOLVED |
194805 | add Error Log view to Java EPP distribution | RESOLVED |
432716 | Consider org.eclipse.recommenders.mylyn.rcp.feature for inclusion into Java package | RESOLVED |
483914 | bug | RESOLVED |
436206 | Re-enable Marketplace Client in Java Package | RESOLVED |
481475 | Scroll lock button being disabled | RESOLVED |
350079 | EGit should be by included in Java package | RESOLVED |
355058 | update repository locations for Juno | RESOLVED |
275767 | [Galileo M7] FileNotFoundException when updating Mylyn | RESOLVED |
275719 | [Galileo M7] packages do not have dropins folder | RESOLVED |
279203 | Add and enable Mylyn update site by default | RESOLVED |
281448 | [update] manager talking to update sites not available | RESOLVED |
549138 | Mylyn cannot be removed from Java IDE package | RESOLVED |
275558 | [Galileo M7] welcome view is not displayed on first startup | RESOLVED |
275523 | [Galileo M7] features appear twice in the about dialog | RESOLVED |
246466 | Missing/extra update sites when installing in either C:program file or C: | RESOLVED |
248976 | 'IDE for Java Developers' package is too restrictive by specifying Java 1.5 as required | RESOLVED |
275520 | [Galileo M7] package does not have any update sites | RESOLVED |
275521 | Improve branding for Galileo java package | RESOLVED |
297341 | EPP web page 'Download Milestone' link points to old builds | RESOLVED |
287566 | error on update after clean install | RESOLVED |
341705 | I tried to load the eclipse environment in Win Vista OS and got problems restoring workbench... | RESOLVED |
343869 | Add WindowBuilder Core and Swing to the Java package | RESOLVED |
346703 | Inclusion of m2e marketplace on help menu causing confusion | RESOLVED |
348157 | intrusive 'preview?' dialog on startup, from WindowBuilder | RESOLVED |
340312 | Indigo Java package logs lots of output | RESOLVED |
334180 | package contains duplicate (and modified?) bundles | RESOLVED |
313818 | Bugzilla connector does not load on Java 1.5 due to missing java.xml.bind bundle | RESOLVED |
306817 | Cannot update from M5 to Eclipse 3.6 M6 | RESOLVED |
311613 | java IDE / m6 / linux has an EclispeCon splash screen? | RESOLVED |
507104 | Include EclEmma in Java Package | RESOLVED |
507515 | Issue encountered when updating and reinstalling ABAP Development tools on NEON version. | CLOSED |
532067 | Open Bugs | CLOSED |
530726 | Mac OS X(Cocoa)64位下载连接无效 | CLOSED |
515622 | Eclipse will not run | CLOSED |
526343 | Constantly returning error message when opening the program | CLOSED |
501518 | Exception while updating external folders | CLOSED |
521654 | Getting error while starting Apache server | CLOSED |
529170 | MacOs didnt open the program | CLOSED |
548444 | The Java GUI is too big | CLOSED |
497204 | resource in project, but error says not open | CLOSED |
547604 | Can't Install software | CLOSED |
548562 | I am not able to update because of unfound repositories. | CLOSED |
550404 | sgfghg | CLOSED |
551635 | I can't run eclipse without having a bug on it. | CLOSED |
543464 | 2018-12 Installation Error | CLOSED |
543054 | Eclipse crashing while looking at files | CLOSED |
540168 | java 11 | CLOSED |
539041 | Unable to Install | CLOSED |
541760 | Missing Java Developer links for 2018-12 M3 | CLOSED |
542080 | Problems occurred when invoking code from plug-in: 'org.eclipse.ui.views.properties.tabbed'. | CLOSED |
543011 | java.io.FileWriter, the File cannot be deleted | CLOSED |
534760 | Simple compilation fails in Eclipse Oxygen.3a | CLOSED |
457081 | Add Error Reporting to Java Package | CLOSED |
435919 | Add 'Eclipse Code Recommenders' to 'This package includes' list | CLOSED |
435449 | Add org.eclipse.recommenders.snipmatch.rcp.feature to java-package | CLOSED |
436109 | update java package maintainer information | CLOSED |
455363 | Allow users to uninstall features from a package | CLOSED |
461540 | Unarchiving error | CLOSED |
414385 | the eclipsec executable launcher was unable to locate its companion shared library | CLOSED |
384532 | The Eclipse executable launcher was unable to locate its companion shared library | CLOSED |
330226 | Inclusion of m2e | CLOSED |
304968 | LinkageError when trying to use Eclipse to run (PDE) Ant scripts | CLOSED |
349028 | fix provider name for org.eclipse.wb.discovery.* | CLOSED |
353613 | Add EGit 1.1 to java-package | CLOSED |
381216 | Zip file for Java IDE RC1 package requires a password? | CLOSED |
464220 | Bug | CLOSED |
470912 | p2 can't find epp repo for Mars release | CLOSED |
482370 | thanks | CLOSED |
482285 | Mars.1 splash screen does not show progress bar after using console | CLOSED |
484535 | An error removing AppEngine from the project | CLOSED |
494695 | Didn't update from old version | CLOSED |
495806 | Suboptimal 'Visit' link on About Eclipse Features page | CLOSED |
480756 | Switch to root level features to allow users to remove unwanted features | CLOSED |
478619 | Webapp | CLOSED |
476546 | Eclipse Mars.1 RC2 for Java Developers includes CVS cheat sheets but no CVS support | CLOSED |
476553 | Installed Code Recommenders Snipmatch and Mylyn Integration features do not *show* under Installation Details | CLOSED |
477195 | Maintainer/tester information outdated | CLOSED |
477572 | p | CLOSED |
497192 | Eclipse Mars does not open in Windows 10 Pro | CLOSED |
Bugs listed in italics indicate the bug has been moved to another project.
File a Bug on this Package
New and Noteworthy
Eclipse PlatformEclipse Mylyn
EGit
Eclipse Code Recommenders
![Download Jdk 1.8 Mac Download Jdk 1.8 Mac](/uploads/1/2/8/2/128252160/223924618.jpg)
Testing Details
The Java Development Kit (JDK), officially named 'Java Platform Standard Edition' or 'Java SE', is needed for writing Java programs. The JDK is freely available from Sun Microsystems (now part of Oracle). The mother site for JDK (Java SE) is http://www.oracle.com/technetwork/java/javase/overview/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
Reference: 'Java Version History' @ https://en.wikipedia.org/wiki/Java_version_history.
- JDK Alpha and Beta (1995): Sun Microsystem announced Java in September 23, 1995.
- JDK 1.0 (January 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 1997): Introduced AWT event model, inner class, JavaBean, JDBC, and RMI.
- J2SE 1.2 (JDK 1.2) (December 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 & Feel, and Drag & Drop). Also introduced Collection Framework and JIT compiler.
- J2SE 1.3 (JDK 1.3) (May 2000): Introduced Hotspot JVM.
- J2SE 1.4 (JDK 1.4) (February 2002): Introduced
assert
statement, non-blocking IO (nio
), logging API, image IO, Java webstart, regular expression (regex) support. - J2SE 5.0 (JDK 5) (September 2004): Officially called 5.0 instead of 1.5 (by dropping the 1.). Introduced generics, autoboxing/unboxing, annotation, enum, varargs, for-each loop, static import. See 'JDK 5 New Features'.
- Java SE 6 (JDK 6) (December 2006): Renamed J2SE to Java SE (Java Platform Standard Edition). No new language features. See 'JDK 6 New Features'.
- Java SE 7 (JDK 7) (July 2011): First version after Oracle purchased Sun Microsystem - aslo called OracleJDK. Introduced Strings in
switch
statement, Binary integer literals, allowing underscores in numeric literals, improved type inference for generic instance creation (or diamond operator<>
), Catching multiple exception types and rethrowing exceptions with improved type checking. See 'JDK 7 New Features'. - Java SE 8 (JDK 8) (LTS) (March 2014): Included support for Lambda expressions, default and static methods in interfaces, improved collection, and JavaScript runtime. Also integrated JavaFX graphics subsystem. See 'JDK 8 New Features'.
- Java SE 9 (JDK 9) (September 21, 2017): Introduced modularization of the JDK (
module
) under project Jigsaw, the Java Shell (jshell
), and more. See 'JDK 9 New Features'. - Java SE 10 (18.3) (JDK 10) (March 2018): Introduced
var
for type inference local variable (similar to JavaScript). Introduced time-based release versioning with two releases each year, in March and September, denoted asYY.M.
Removed native-header generation tooljavah
. See 'JDK 10 New Features'. - Java SE 11 (18.9) (LTS) (JDK 11) (September 2018): Extended
var
to lambda expression. Standardize HTTP client injava.net.http
. Support TLS 1.3. Clean up the JDK and the installation package (removed JavaFX, JavaEE, CORBA modules, deprecated Nashorn JavaScript engine). OracleJDK is no longer free for commercial use, but OpenJDK is still free. See 'JDK 11 New Features'. - Java SE 12 (19.3) (JDK 12) (March 2019): Switch Expression (preview). See 'JDK 12 New Features'.
- Java SE 13 (19.9) (JDK 13) (September 2019): Switch Expression (preview), Multi-line Text Block (preview). See 'JDK 13 New Features'.
- Java SE 14 (20.3) (JDK 14) (March 2020): Records (preview)
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' ⇒ (optional) '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 13.0.{x}', where {x} denotes a fast running security-update number ⇒ Click the 'Oracle JDK Download' button.
- Under 'Java SE Development Kit 13.0.{x}' ⇒ Check 'Accept License Agreement'.
- Choose the JDK for your operating system, i.e., 'Windows'. Download the 'exe' installer (e.g., '
jdk-13.0.{x}_windows-x64_bin.exe
' - about 159MB).
Step 2: Install JDK
Run the downloaded installer (e.g., '
jdk-13.0.{x}_windows-x64_bin.exe
'), which installs both the JDK and JRE.By default, JDK is installed in directory '
C:Program FilesJavajdk-13.0.{x}
', where {x}
denotes the update number. Accept the defaults and follow the screen instructions to install JDK.Use your 'File Explorer', navigate to
'C:Program FilesJava'
to inspect the sub-directories. Take note of your JDK installed directoryjdk-13.0.{x}
, in particular, the update number {x}
, 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' Command Prompt (
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.To edit the
PATH
environment variable in Windows 10:- Launch 'Control Panel' ⇒ (Optional) 'System and Security' ⇒ 'System' ⇒ Click 'Advanced system settings' on the left pane.
- Switch to 'Advanced' tab ⇒ Click 'Environment Variables' button.
- Under 'System Variables' (the bottom pane), scroll down to select variable 'Path' ⇒ Click 'Edit...'.
- For Newer Windows 10:
You shall see a TABLE listing all the existing PATH entries (if not, goto next step). Click 'New' ⇒ Click 'Browse' and navigate to your JDK's 'bin
' directory, i.e., 'c:Program FilesJavajdk-13.0.{x}bin
', where{x}
is your installation update number ⇒ Select 'Move Up' to move this entry all the way to the TOP. - For Older Windows 10 (Time to change your computer!):
(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, APPEND 'c:Program FilesJavajdk-13.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.
Note: If you have started CMD, you need to re-start for the new environment settings to take effect.
Step 4: Verify the JDK Installation
Launch a
CMD
via one of the following means:- Click 'Search' button ⇒ Type 'cmd' ⇒ Choose 'Command Prompt', or
- Right-click 'Start' button ⇒ run... ⇒ enter 'cmd', or
- 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 JDK's 'bin
' is listed in thePATH
. - 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
'. 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, NotePad++, Sublime Text, 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 (Search ⇒ enter 'cmd' ⇒ select 'Command Prompt').
- Set the Current Drive to the drive where you saved your source file '
Hello.java
'.
If you use drive 'c', skip this step.
Else if you use drive 'd
', enter 'd:
' as follow: - 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 '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: (For Advanced Users Only) JDK's Source Code
Source code for JDK is provided and kept in '
<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
', to learn how experts program.How to Install JDK on macOS
Step 1: Check if 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 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'. - 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 13.0.{x}', where {x} denotes a fast running security-update number ⇒ Click the 'Oracle JDK' 'Download' button.
- Under 'Java SE Development Kit 13.0.{x}' ⇒ Check 'Accept License Agreement'.
- Choose the JDK for your operating platform, i.e., macOS. Download the DMG installer (e.g,
jdk-13.0.{x}_osx-x64_bin.dmg
- about 172MB).
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 macOS, the home directory of the current user can be referenced as '~
'. Hence, this new directory can be referenced as '~/myProject
'. - Use a programming text editor (such as Sublime Text or Atom) to input the following source code and save as '
Hello.java
' under the directory '~/myProject
'.
(If you use macOS'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:
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 x.x.x
') 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 11.0.{x}' ⇒ Click JDK's 'Download' ⇒ Under 'Java SE Development Kit 11.0.{x}' ⇒ Check 'Accept License Agreement' ⇒ Select 'Linux', '
tar.gz
' package, (e.g., 'jdk-13.0.{x}-linux-x64_bin.tar.gz
' - 171MB).
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/jdk-13.0.{x}
', where{x}
is the update 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:
- [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 '{x}
' 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:
Source-Code Editors & IDEs for Java Programming
Eclipse IDE
- 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'.
NetBeans IDE
- 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'.
Visual Studio (VS) Code IDE
Click HERE, look for 'VS Code for Java Programming'
Sublime Text (for Windows, macOS, Linux)
Click HERE, look for 'Sublime Text for Java Programming'
Atom (for Windows, macOS, Linux)
[TODO]
TextPad (for Windows only)
Click HERE, look for 'TextPad for Java Programming'.
NotePad++ (for Windows only)
Click HERE, look for 'NotePad++ for Java Programming'.
(JDK 11) Launch Single-Source-File New Feature
From JDK 11, you can compile/run a single-file program in one step, without explicit compilation.
- Write a '
Hello.java
' (see previous section). - Delete '
Hello.class
', if it exists. - You can compile/run '
Hello.java
' in one command as follows:
Notes:
- This is applicable to single source-file only.
- No need to use
javac
to compile the program. - It compiles in memory (without producing a
.class
file), and run. - This feature is introduced for beginners to learn Java, and for professionals to test a Java feature.
- The filename and classname need not be the same.
How To Set JAVA_HOME Environment Variable
Many Java applications (such as Tomcat) require the environment variable
JAVA_HOME
to be set to the JDK installed directory.See 'How to set JAVA_HOME for Windows' or 'How to set JAVA_HOME for macOS/Linux'.
Common Errors in installing JDK
(Advanced) External JAR Files and Native Libraries
Notes: This section is applicable to JDK prior to JDK 9. JDK 9 introduces a new level called 'module' on top of package, and '
jmod
' files for Java modules. Need to revise this section for JDK 9.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/macOS).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:
- Copy all the JAR files of the external packages to the Java's Extension Directories (NOT applicable to JDK 9).
- For Windows, the JDK extension directory is located at '
<JAVA_HOME>jrelibext
' (e.g., 'c:Program FilesJavajdk1.8.0_xxjrelibext
'). - For macOS, 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 macOS: 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 (Archive) library), or '.so
' (Unix's Shared Object 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
'.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
(macOS / Unix). 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,
Eclipse/NetBeans
Using an IDE can greatly simplifies inclusion of external packages. Read 'Eclipse How-To' or 'NetBeans How-To'.