Shopy 101
← Installation Sign in to download

Getting started Java Programming
Installation
Compilation
Navigate Getting Started topic: ()

In order to make use of the content in this book, you would need to follow along each and every tutorial rather than simply reading through the book. But to do so, you would need access to a computer with the Java platform installed on it the Java platform is the basic prerequisite for running and developing Java code, thus it is divided into two essential pieces of software:

  • the Java Runtime Environment (JRE), which is needed to run Java applications and applets;
  • the Java Development Kit (JDK), which is needed to develop those Java applications and applets.

However as a developer, you would only require the JDK which comes equipped with a JRE as well.

As Java is just a programming language that allows you to program the computer, it has multiple implementations available. The most popular implementation of JDK and JRE are the "Oracle Java SE" (formerly known as Sun JDK), maintained by Oracle as a commercial release. However another similarly popular implementation is the OpenJDK, with the benefit of being free software that could distribute freely under GPL v2 without the requirement of accepting the "Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX". The third option - the GCJ, as part of the GNU Compiler Collection, would also supply the JDK and JRE.

Given below are installation instruction for the Oracle Java SE JDK for various operating systems:

cmd</code> at the prompt:\n<div class=\"noprint\">[[Image:Java Programming Run dialog.png|frame|center|<span id=\"figure-1\">Figure 1.1: Run dialog</span>]]</div>\n|-\n|valign=\"top\"|2.\n|In the command window with black background graced with white text, type the following command:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''JRE availability check'''\n<pre style=\"background-color:#000; color:#fff;\">\njava -version\n</pre>"}},"i":3}},"\n\nIf you get an error, such as:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Other output error'''\n<pre style=\"background-color:#000; color:#fff;\">\nBad command or file name\n</pre>"}},"i":4}},"\n\n..then the JDK may not be installed or it may not be in your path.\n|}\n\n: ''To learn more about the Command Prompt syntax, take a look at this [http://tnd.com/camosun/elex130/dostutor1.html MS-DOS tutorial].''\n\nYou may have other versions of Java installed; this command will only show the first in your PATH. You will be made familiar with the PATH environment variable later in this text. For now, if you have no idea what this is all about. Read through towards the end and we will provide you with a step-by-step guide on how to set your own environment variables.\n\nYou can use your system's file search utilities to see if there is a <code>javac.exe</code> executable installed. If it is, and it is a recent enough version (Java 1.4.2 or Java 1.5, for example), you should put the <code>bin</code> directory that contains <code>javac</code> in your system path. The Java runtime, <code>java</code>, is often in the same <code>bin</code> directory.\n\nIf the installed version is older (i.e. it is Java 1.3.1 or Java 1.4.2 and you wish to use the more recent Java 5 release), you should proceed below with downloading and installing a JDK.\n\nIt is possible that you have the Java runtime (JRE), but not the JDK. In that case the <code>javac</code> program won't be found, but the <code>java -version</code> will print the JRE version number.\n\n==== Availability check for JDK ====\nSome Windows based systems come built-in with the JRE, however for the purposes of writing Java code by following the tutorials in this book, you would require the JDK nevertheless. The Java Development Kit (JDK) is necessary to build Java programs. First, check to see if a JDK is already installed on your system. To do so, first open a command window and execute the command below.\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Availability check'''\n<pre style=\"background-color:#000; color:#fff;\">\njavac -version\n</pre>"}},"i":5}},"\n\nIf the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.\n\n==== Advanced availability check options on Windows platform ====\nOn a machine using the Windows operating system, one can invoke the Registry Editor utility by typing <code>REGEDIT</code> in the Run dialog. In the window that opens subsequently, if you traverse through the hierarchy <code>[[w:HKEY_LOCAL_MACHINE#HKEY_LOCAL_MACHINE|HKEY_LOCAL_MACHINE]] > SOFTWARE > JavaSoft > Java Development Kit</code> on the left-hand.\n\nThe resultant would be similar to [[#figure-2|figure 1.2]], with the only exception being the version entries for the Java Development Kit. At the time of writing this manuscript, the latest version for the Java Development Kit available from the Internet was 1.7 as seen in the Registry entry. If you see a resultant window that resembles the one presented above, it would prove that you have Java installed on your system, otherwise it is not.\n\n<div class=\"noprint\">[[Image:Java Programming Regedit Av.png|frame|center|<span id=\"figure-2\">Figure 1.2: Registry Editor</span>]]</div>\n\n",{"template":{"target":{"wt":"XNote","href":"./Template:XNote"},"params":{"1":{"wt":"Caution should be exercised when traversing through the Registry Editor. Any changes to the keys and other entries may change the way your Windows operating system normally works. Even minor changes may result into catastrophic failures of the normal working of your machine. Better that you don't modify or tend to modify anything whilst you are in the Registry Editor."}},"i":6}},"\n\n==== Download instructions ====\nTo acquire the latest JDK (version 7), you can manually [http://www.oracle.com/technetwork/java/javase/downloads/index.html download the Java software] from the Oracle website.\n\nFor the convenience of our readers, the following table presents direct links to the latest JDK for the Windows operating system.\n{|class=\"wikitable sortable\"\n|-\n|Operating system\n|Setup Installer\n|License\n|-\n|Windows x86\n|[http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-windows-i586.exe Download]\n|[http://www.oracle.com/technetwork/java/javasebusiness/documentation/java-se-bcl-license-430205.html Oracle Binary Code License Agreement]\n|-\n|Windows x64\n|[http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-windows-x64.exe Download]\n|[http://www.oracle.com/technetwork/java/javasebusiness/documentation/java-se-bcl-license-430205.html Oracle Binary Code License Agreement]\n|}\nYou must follow the instructions for the setup installer wizard step-by-step with the default settings to ensure that Java is properly installed on your system. Once the setup is completed, it is highly recommended to restart your Windows operating system.\n\nIf you kept the default settings for the setup installer wizard, your JDK should now be installed at '''C:\\Program Files\\Java\\jdk1.7.0_01'''. You would require the location to your '''bin''' folder at a later time &mdash; this is located at '''C:\\Program Files\\Java\\jdk1.7.0_01\\bin''' It may be a hidden file, but no matter. Just don't use Program Files (x86)\\ by mistake unless that's where the files were installed by Java.\n\n====Updating environment variables====\nIn order for you to start using the JDK compiler utility with the Command Prompt, you would need to set the environment variables that points to the '''bin''' folder of your recently installed JDK. To set permanently your environment variables, follow the steps below.\n\n{|style=\"padding-left:1.5em;\"\n|-\n|\n|-\n|valign=\"top\"|1.\n|To open '''System Properties''' dialog box use, the Control Panel or type the following command in the command window:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''System properties'''\n<pre style=\"background-color:#000; color:#fff;\">\nrundll32 shell32.dll,Control_RunDLL sysdm.cpl\n</pre>"}},"i":7}},"\n|-\n|valign=\"top\"|2.\n|Navigate to the '''Advanced''' tab on the top, and select '''Environment Variables...'''\n|-\n|valign=\"top\"|3.\n|Under '''System variables''', select the variable named '''Path''' and click '''Edit...'''\n|-\n|valign=\"top\"|4.\n|In the '''Edit System Variable''' dialog, go to the '''Variable value''' field. This field is a list of directory paths separated by semi-colons (;).\n|-\n|valign=\"top\"|5.\n|To add a new path, append the location of your JDK '''bin''' folder separated by a semi-colon (;).\n|-\n|valign=\"top\"|6.\n|Click '''OK''' on every opened dialog to save changes and get past to where you started.\n|}\n\n====Start writing code====\nOnce you have successfully installed the JDK on your system, you are ready to program code in the Java programming language. However, to write code, you would need a decent text editor. Windows comes with a default text editor by default &mdash; '''Notepad'''. In order to use notepad to write code in Java, you need to follow the steps below:\n{|style=\"padding-left:1.5em;\"\n|-\n|\n|-\n|valign=\"top\"|1.\n|Click '''Start''' &rsaquo; '''All Programs''' &rsaquo; '''Accessories''' &rsaquo; '''Notepad''' to invoke the application.\n|-\n|\n|Alternatively, you can also press ",{"template":{"target":{"wt":"keypress","href":"./Template:Keypress"},"params":{"1":{"wt":"Win"}},"i":8}},"+",{"template":{"target":{"wt":"keypress","href":"./Template:Keypress"},"params":{"1":{"wt":"R"}},"i":9}}," to open the '''Run''' dialog. With the dialog open, type the following command at the prompt:\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Notepad launching'''\n<pre style=\"background-color:#000; color:#fff;\">\nnotepad\n</pre>"}},"i":10}},"\n|-\n|valign=\"top\"|2.\n|Once the '''Notepad''' application has fired up, you can use the editor to write code for the Java programming language.\n|}\n",{"template":{"target":{"wt":"Hidden end","href":"./Template:Hidden_end"},"params":{},"i":11}}]}' id="mwHA">
Installation instructions for Windows

Availability check for JRE

The Java Runtime Environment (JRE) is necessary to execute Java programs. To check which version of Java Runtime Environment (JRE) you have, follow the steps below.

1. For Windows Vista or Windows 7, click Start Control Panel System and Maintenance System.
For Windows XP, click Start Control Panel System.
For Windows 2000, click Start Settings Control Panel System.
Alternatively, you can also press ⊞ Win+R to open the Run dialog. With the dialog open, type cmd at the prompt:
Figure 1.1: Run dialog
2. In the command window with black background graced with white text, type the following command:
Standard input or output JRE availability check
java -version

If you get an error, such as:

Standard input or output Other output error
Bad command or file name

..then the JDK may not be installed or it may not be in your path.

To learn more about the Command Prompt syntax, take a look at this MS-DOS tutorial.

You may have other versions of Java installed; this command will only show the first in your PATH. You will be made familiar with the PATH environment variable later in this text. For now, if you have no idea what this is all about. Read through towards the end and we will provide you with a step-by-step guide on how to set your own environment variables.

You can use your system's file search utilities to see if there is a javac.exe executable installed. If it is, and it is a recent enough version (Java 1.4.2 or Java 1.5, for example), you should put the bin directory that contains javac in your system path. The Java runtime, java, is often in the same bin directory.

If the installed version is older (i.e. it is Java 1.3.1 or Java 1.4.2 and you wish to use the more recent Java 5 release), you should proceed below with downloading and installing a JDK.

It is possible that you have the Java runtime (JRE), but not the JDK. In that case the javac program won't be found, but the java -version will print the JRE version number.

Availability check for JDK

Some Windows based systems come built-in with the JRE, however for the purposes of writing Java code by following the tutorials in this book, you would require the JDK nevertheless. The Java Development Kit (JDK) is necessary to build Java programs. First, check to see if a JDK is already installed on your system. To do so, first open a command window and execute the command below.

Standard input or output Availability check
javac -version

If the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.

Advanced availability check options on Windows platform

On a machine using the Windows operating system, one can invoke the Registry Editor utility by typing REGEDIT in the Run dialog. In the window that opens subsequently, if you traverse through the hierarchy HKEY_LOCAL_MACHINE > SOFTWARE > JavaSoft > Java Development Kit on the left-hand.

The resultant would be similar to figure 1.2, with the only exception being the version entries for the Java Development Kit. At the time of writing this manuscript, the latest version for the Java Development Kit available from the Internet was 1.7 as seen in the Registry entry. If you see a resultant window that resembles the one presented above, it would prove that you have Java installed on your system, otherwise it is not.

Figure 1.2: Registry Editor
Note Caution should be exercised when traversing through the Registry Editor. Any changes to the keys and other entries may change the way your Windows operating system normally works. Even minor changes may result into catastrophic failures of the normal working of your machine. Better that you don't modify or tend to modify anything whilst you are in the Registry Editor.

Download instructions

To acquire the latest JDK (version 7), you can manually download the Java software from the Oracle website.

For the convenience of our readers, the following table presents direct links to the latest JDK for the Windows operating system.

Operating system Setup Installer License
Windows x86 Download Oracle Binary Code License Agreement
Windows x64 Download Oracle Binary Code License Agreement

You must follow the instructions for the setup installer wizard step-by-step with the default settings to ensure that Java is properly installed on your system. Once the setup is completed, it is highly recommended to restart your Windows operating system.

If you kept the default settings for the setup installer wizard, your JDK should now be installed at C:\Program Files\Java\jdk1.7.0_01. You would require the location to your bin folder at a later time this is located at C:\Program Files\Java\jdk1.7.0_01\bin It may be a hidden file, but no matter. Just don't use Program Files (x86)\ by mistake unless that's where the files were installed by Java.

Updating environment variables

In order for you to start using the JDK compiler utility with the Command Prompt, you would need to set the environment variables that points to the bin folder of your recently installed JDK. To set permanently your environment variables, follow the steps below.

1. To open System Properties dialog box use, the Control Panel or type the following command in the command window:
Standard input or output System properties
rundll32 shell32.dll,Control_RunDLL sysdm.cpl
2. Navigate to the Advanced tab on the top, and select Environment Variables...
3. Under System variables, select the variable named Path and click Edit...
4. In the Edit System Variable dialog, go to the Variable value field. This field is a list of directory paths separated by semi-colons (;).
5. To add a new path, append the location of your JDK bin folder separated by a semi-colon (;).
6. Click OK on every opened dialog to save changes and get past to where you started.

Start writing code

Once you have successfully installed the JDK on your system, you are ready to program code in the Java programming language. However, to write code, you would need a decent text editor. Windows comes with a default text editor by default Notepad. In order to use notepad to write code in Java, you need to follow the steps below:

1. Click Start All Programs Accessories Notepad to invoke the application.
Alternatively, you can also press ⊞ Win+R to open the Run dialog. With the dialog open, type the following command at the prompt:
Standard input or output Notepad launching
notepad
2. Once the Notepad application has fired up, you can use the editor to write code for the Java programming language.
\njava -version\n</pre>"}},"i":1}},"\n\nIf you get something like this:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Output on a particular Kubuntu 12.10 installation, with OpenJDK as the provider of JDK and JRE'''\n<pre style=\"background-color:#000; color:#fff;\">\njava version \"1.7.0_09\"\nOpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)\nOpenJDK Client VM (build 23.2-b09, mixed mode, sharing)\n</pre>"}},"i":2}},"\n\n... then a JRE is installed. If you get an error, such as:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Output error'''\n<pre style=\"background-color:#000; color:#fff;\">\njava: command not found\n</pre>"}},"i":3}},"\n\n... then the JDK may not be installed or it may not be in your PATH.\n|}\n\nYou may have other versions of Java installed; this command will only show the first in your PATH. You will be made familiar with the PATH environment variable later in this text. For now, if you have no idea what this is all about, read through towards the end and we will provide you with a step-by-step guide on how to set your own environment variables.\n\nYou can use your system's file search utilities to see if there is a <code>javac</code> executable installed. If it is, and it is a recent enough version, you should put the <code>bin</code> directory that contains <code>javac</code> in your system PATH. The Java runtime, <code>java</code>, is often in the same <code>bin</code> directory.\n\nIf the installed version is older (i.e. it is Java 5 and you wish to use the more recent Java 7 release), you should proceed below with downloading and installing a JDK.\n\nIt is possible that you have the Java runtime (JRE), but not the JDK. In that case the <code>javac</code> program won't be found, but the <code>java -version</code> will print the JRE version number.\n\n==== Availability check for JDK ====\nThe Java Development Kit (JDK) is necessary to build Java programs. For our purposes, you must use a JDK. First, check to see if a JDK is already installed on your system. To do so, first open a terminal window and execute the command below.\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Availability check'''\n<pre style=\"background-color:#000; color:#fff;\">\njavac -version\n</pre>"}},"i":4}},"\n\nIf the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.\n\n====Installation using Terminal====\nDownloading and installing the Java platform on Linux machines is very easy and straightforward. You have two choices to install the Java platforms: using a package manager such as DPKG/APT, YUM/RPM etc., or directly install them using the binary package. To use the terminal to download and install the Oracle Java SE platform, follow the instructions below.\n{|style=\"padding-left:1.5em;\"\n|-\n|\n|-\n|valign=\"top\"|1.\n|Open the '''Terminal''' window.\n|-\n|valign=\"top\"|2.\n|At the prompt, type in the line followed by the name of your package manager as shown below:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Retrieving the java packages'''\n<pre style=\"background-color:#000; color:#fff;\">\n# APT - Ubuntu, Linux Mint\n$ sudo add-apt-repository ppa:webupd8team/java\n$ sudo apt update\n$ sudo apt-get install oracle-java8-installer\n# APT - Debian, etc.\n$ echo \"deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main\" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list\n$ echo \"deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main\" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list\n$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886\n$ sudo apt-get update\n$ sudo apt-get install oracle-java8-installer\n# Portage - Gentoo\n# You need to accept the license and fetch the source code manually from http://www.oracle.com/technetwork/java/javase/downloads/index.html\n# and save it to /usr/portage/distfiles\n$ echo \"dev-java/oracle-jdk-bin Oracle-BCLA-JavaSE\" | sudo tee -a /etc/portage/package.license # Accept the Oracle License\n$ emerge oracle-jdk-bin\n# Pacman - Arch\n$ sudo pacman -S jdk8-openjdk\n</pre>"}},"i":5}},"\n|-\n|valign=\"top\"|3.\n|All Java softwares should be installed and instantly available now.\n|}\n\n====Download instructions====\nAlternatively, you can manually [http://www.oracle.com/technetwork/java/javase/downloads/index.html download the Java software] from the Oracle website.\n\nFor the convenience of our readers, the following table presents direct links to the latest JDK for the Linux operating system.\n{|class=\"wikitable sortable\"\n|-\n|Operating system\n|RPM\n|Tarball\n|License\n|-\n|Linux x86\n|[http://download.oracle.com/otn-pub/java/jdk/7u7-b10/jdk-7u7-linux-i586.rpm Download]\n|[http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.tar.gz Download]\n|[http://www.oracle.com/technetwork/java/javasebusiness/documentation/java-se-bcl-license-430205.html Oracle Binary Code License Agreement]\n|-\n|Linux x64\n|[http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.rpm Download]\n|[http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz Download]\n|[http://www.oracle.com/technetwork/java/javasebusiness/documentation/java-se-bcl-license-430205.html Oracle Binary Code License Agreement]\n|}\n\n====Start writing code====\nThe most widely available text editor on GNOME desktops is '''Gedit''', while on the KDE desktops, one can find '''Kate'''. Both these editors support syntax highlighting and code completion and therefore are sufficient for our purposes.\n\nHowever, if you require a robust and standalone text-editor like the Notepad++ editor on Windows, you would require the use of the minimalistic editor loaded with features &ndash; '''SciTE'''. Follow the instructions below if you wish to install '''SciTE''':\n{|style=\"padding-left:1.5em;\"\n|-\n|\n|-\n|valign=\"top\"|1.\n|Open the '''Terminal''' window.\n|-\n|valign=\"top\"|2.\n|At the prompt, write the following:\n\n",{"template":{"target":{"wt":"XConsole","href":"./Template:XConsole"},"params":{"1":{"wt":"'''Retrieving the java packages'''\n<pre style=\"background-color:#000; color:#fff;\">\n$ sudo apt-get install scite\n</pre>"}},"i":6}},"\n|-\n|valign=\"top\"|3.\n|You should now be able to use SciTE for your programming needs. You may also want to try Geany. Installation instructions are similar to those for SciTE.\n|}\n",{"template":{"target":{"wt":"Hidden end","href":"./Template:Hidden_end"},"params":{},"i":7}}]}' id="mwKA">
Installation instructions for GNU/Linux

Availability check for JRE

The Java Runtime Environment (JRE) is necessary to execute Java programs. To check which version of JRE you have, follow the steps below.

1. Open the Terminal window.
2. Type the following command:
Standard input or output JRE availability check
java -version

If you get something like this:

Standard input or output Output on a particular Kubuntu 12.10 installation, with OpenJDK as the provider of JDK and JRE
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (7u9-2.3.3-0ubuntu1~12.10.1)
OpenJDK Client VM (build 23.2-b09, mixed mode, sharing)

... then a JRE is installed. If you get an error, such as:

Standard input or output Output error
java: command not found

... then the JDK may not be installed or it may not be in your PATH.

You may have other versions of Java installed; this command will only show the first in your PATH. You will be made familiar with the PATH environment variable later in this text. For now, if you have no idea what this is all about, read through towards the end and we will provide you with a step-by-step guide on how to set your own environment variables.

You can use your system's file search utilities to see if there is a javac executable installed. If it is, and it is a recent enough version, you should put the bin directory that contains javac in your system PATH. The Java runtime, java, is often in the same bin directory.

If the installed version is older (i.e. it is Java 5 and you wish to use the more recent Java 7 release), you should proceed below with downloading and installing a JDK.

It is possible that you have the Java runtime (JRE), but not the JDK. In that case the javac program won't be found, but the java -version will print the JRE version number.

Availability check for JDK

The Java Development Kit (JDK) is necessary to build Java programs. For our purposes, you must use a JDK. First, check to see if a JDK is already installed on your system. To do so, first open a terminal window and execute the command below.

Standard input or output Availability check
javac -version

If the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.

Installation using Terminal

Downloading and installing the Java platform on Linux machines is very easy and straightforward. You have two choices to install the Java platforms: using a package manager such as DPKG/APT, YUM/RPM etc., or directly install them using the binary package. To use the terminal to download and install the Oracle Java SE platform, follow the instructions below.

1. Open the Terminal window.
2. At the prompt, type in the line followed by the name of your package manager as shown below:
Standard input or output Retrieving the java packages
# APT - Ubuntu, Linux Mint
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt update
$ sudo apt-get install oracle-java8-installer
# APT - Debian, etc.
$ echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
$ echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
# Portage - Gentoo
# You need to accept the license and fetch the source code manually from http://www.oracle.com/technetwork/java/javase/downloads/index.html
#   and save it to /usr/portage/distfiles
$ echo "dev-java/oracle-jdk-bin Oracle-BCLA-JavaSE" | sudo tee -a /etc/portage/package.license # Accept the Oracle License
$ emerge oracle-jdk-bin
# Pacman - Arch
$ sudo pacman -S jdk8-openjdk
3. All Java softwares should be installed and instantly available now.

Download instructions

Alternatively, you can manually download the Java software from the Oracle website.

For the convenience of our readers, the following table presents direct links to the latest JDK for the Linux operating system.

Operating system RPM Tarball License
Linux x86 Download Download Oracle Binary Code License Agreement
Linux x64 Download Download Oracle Binary Code License Agreement

Start writing code

The most widely available text editor on GNOME desktops is Gedit, while on the KDE desktops, one can find Kate. Both these editors support syntax highlighting and code completion and therefore are sufficient for our purposes.

However, if you require a robust and standalone text-editor like the Notepad++ editor on Windows, you would require the use of the minimalistic editor loaded with features SciTE. Follow the instructions below if you wish to install SciTE:

1. Open the Terminal window.
2. At the prompt, write the following:
Standard input or output Retrieving the java packages
$ sudo apt-get install scite
3. You should now be able to use SciTE for your programming needs. You may also want to try Geany. Installation instructions are similar to those for SciTE.
\njava -version\n</pre>"}},"i":1}},"\n\nIf the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.\n",{"template":{"target":{"wt":"Hidden end","href":"./Template:Hidden_end"},"params":{},"i":2}}]}' id="mwNA">
Installation instructions for Mac OS

On Mac OS, both the JRE and the JDK are already installed. However, the version installed was the latest version when the computer was purchased, so you may want to update it.

Updating Java for Mac OS

  1. Go to the Java download page.
  2. Mechanically accept Oracle's license agreement.
  3. Click on the link for Mac OS X.
  4. Run the installer package.

Availability check for JDK

The Java Development Kit (JDK) is necessary to build Java programs. For our purposes, you must use a JDK. First, check to see if a JDK is already installed on your system. To do so, first open a terminal window and execute the command below.

Standard input or output Availability check
java -version

If the JDK is installed and on your executable path, you should see some output which tells you the command line options. The output will vary depending on which version is installed and which vendor provided the Java installation.

Installation instructions for Solaris
Clipboard

To do:
Add a section describing the installation of Java onto Solaris machines. Incorporate some of the information provided in the commented section of this page.

No Install Option for Programming Online

If you already have the JRE installed, you can use the Java Wiki Integrated Development Environment (JavaWIDE) to code directly in your browser, no account or special software required.

Click here to visit the JavaWIDE Sandbox to get started.

For more information, click here to visit the JavaWIDE site.

Getting started Java Programming
Installation
Compilation