Here’s what we’re going to do:
- Download the basic Java tools (the JDK) and install it.
- Make something with it.
Updated on 2020/02/09
This series is intended as a raw-beginner-level get-started guide for getting started in building Java applications – on Microsoft Windows. It is not intended as a lesson in how to program, and it is a bit pedantic. I posted this because the online information that’s readily available seems to be a bit of a mess. Even on the main Java websites, some of the information is outdated, wrong, unclear or just poorly written. I think it’s especially important to have this be simple, easy, and correct for beginners.
Java is now owned by Oracle (who acquired Sun Microsystems in 2010). In 2019 Oracle changed their Java License to be more restrictive. They maintain a Oracle Java SE Licensing FAQ here . If you would rather not use that — they also provide the latest OpenJDK release under the open source GPL license.
Versions: The Oracle Java version (under their Oracle Java License) is at Version 8 Update 241 (as of 2020/2/10). However the latest General-Availability JDK (Java Development Kit) release is JDK 13.0.2. Oh no – not confusing at all.
I am here assuming you are running 64-bit Windows and we’ve no need to discuss the 32-bit version, for brevity.
I’d appreciate your feedback comments for improving this article.
Unlike some other programming languages, it can take a bit of scrounging to get setup to produce a decent Java desktop application. Here then is a list of tips for getting started. Please note that these apply only to development under Microsoft Windows (as of 2020 I’m using Windows 10): if you’re using a different operating system then you’ll need to make allowances for the differences. Also, for brevity – I’m simply going to assume you’re working with the current version. If yours is a different version then just allow for this as you read below.
Okay, let’s get started.
or the OpenJDK
(click on one of the above)
Download the Java JDK and install it.
You have selected the Oracle JDK
Your first step is to download the Java JDK (“Java Development Kit”). Assuming you want the latest release, download it from Oracle’s Java SE Development Kit 13 Downloads.
Click on “Accept license agreement, and then download the installer file by clicking on jdk-13.0.2_windows-x64_bin.exe (or similar depending up the version).
Proceed with downloading the file onto your computer.
Double-click that file that you just downloaded to launch the installer. You should see this:
Click “Next >” and from here the installation process is pretty much self-explanatory. In the “Destination Folder” dialog-panel you can just leave the install-to at it’s default value, or you can change it if you wish. Personally I usually set it on my machine to be “C:\Java”.
Click on “Next” to do the installation. It’ll take a moment.
Add your Java compiler’s executable folder to the PATH environmental variable. If you used the default path then you’d add “;C:\Program Files\Java\jdk13.0.2\bin” (or similar, depending upon your version). The initial semicolon is what separates this from the preceding text that is already in the PATH value (unless you want to place this as the first value).
Add a CLASSPATH environment variable, setting it to “C:\Program Files\Java\jdk13.0.2\lib” or whatever your version is.
You selected the OpenJDK Version
Download and install the Java OpenJDK (the Open-source Java Development Kit) by pointing your browser to this page that has the OpenJDK builds.
Select the version you want and click on it to download the corresponding .ZIP file.
Now this next step is not essential, but it can solve an issue for some people. Often when you download a file on Windows, it has a property set on it that, if you right-click on the file and select “Properties”, you will see at the bottom of the “General” tab: “This file came from another computer and might be blocked to help protect this computer.” See figure 5.
You can remove this block by simply checking the “Unblock” checkbox and then selecting “OK”.
This file is not an installer. It is a compressed file that contains the entire directory-tree containing your JDK. Decompress it using your method of choice (I use Winrar).
Now you have a directory-tree under the directory named “jdk-13.0.2” (or similar depending upon the version you chose).
You install this by moving it to where you want it (or you can just leave it there – I don’t care). Personally I place mine within C:\Java\JDK, so that the full path is now “C:\Java\JDK\jdk-13.0.2”. I place it under a separate directory named “JDK” because I use various versions and it seems cleaner to have them all under that one folder.
Add your Java compiler’s executable folder to your PATH environmental variable ( Click here if you are unsure how to add something to your PATH environmental variable ). If you installed your JDK to the same location as I do ( “C:\Java\JDK\jdk-13.0.02” ) then you would add “C:\Java\JDK\jdk-13.0.2\bin” to the PATH environment variable. The various paths within that environment variable are separated from each other using semicolons.
You now have Java
You can test that you’ve accomplished the Java installation successfully by opening a command-line window and typing: “javac -version”. It should respond with “javac 13.0.2” or similar depending upon your version, as you can see in Figure 4.
You can view the official Java documentation here. This has changed during the time since Oracle took over Java. You can just link to the start page for all the documentation, or if you prefer to be able to access it when not online you can download an offline version.
You now have Java installed and are ready to git down for some actual programming. Next up is creating your first command-line programs, and JavaFX.