Updating Java is one of the important things to do when playing Minecraft, as some technical bugs may only be fixed by updating Java.
The Minecraft launcher is bundled with Java version 1.8.0_74, which is used by default. It is possible to change the used Java version in the profile options menu.
What is Java?
Java is a programming language and computing platform. Unlike many other languages, Java does not run directly on the hardware, but in a virtual machine, called the JVM (Java Virtual Machine". Minecraft is written in Java, and uses it for game logic, rendering, and networking.
As of August 24th, 2018, the latest stable Java version is 1.8.0_181, 9.0.4 and 10.0.2, and the latest development builds are 11 early-access build 28 and 12 early-access build 8.
Note: Minecraft will not run with Java 9 or greater unless you remove
-XX:+CMSIncrementalMode from your JVM Arguments.
The latest versions of Java contain important enhancements to help improve performance, stability and security of the Java applications that run on your machine. Installing the latest Java update will ensure that Minecraft will continue to run safely and efficiently.
- As of the 1.12 update, Minecraft requires Java 8 or greater. 
- Minecraft may sometimes crash without being run by a relatively modern version of Java.
- Java updates fix lots of problems and bugs, and typically cause increases in performance.
- Running a server requires your computer to have Java installed instead of the pre-installed Java. See Tutorials/Setting up a server for more information.
Where to download
Obtain the latest stable Java update here.
You can obtain the latest Java 11 development build here.
You can obtain the latest Java 12 development build here.
Please note that development versions of Java may be unstable, thus, could cause unexpected crashes and other issues.
- As the Minecraft launcher is bundled with Java, it is not necessary to install it separately unless you're using a third-party launcher, or wish to use a different version of Java than the one that is included by default.
- If you have a 64-bit machine, it is advised to install the 64-bit version of Java for optimum performance.
- It is not necessary to uninstall all versions of Java currently installed on your machine before attempting to update Java.
- When you install the latest version of Java, it may ask if you want to uninstall older versions of Java, or do it automatically.
- Some systems require administrator privileges to update Java.