Working with an IDE
Creating files in text editors is a little old-fashioned. Of course, you can still do it this way – it’s actually an excellent way of becoming an amazing programmer, but it’s also a very frustrating way. There are tools available to do quite a bit of the heavy work for us and to assist us while writing our code. These tools are called IDEs.
What is an IDE?
An IDE is a software application that comes with everything you need to write, compile, run, and test your code. Using an IDE can make it easier to develop all sorts of programs. Not only that but also debugging and managing your code is easier. Comparatively, you can think of an IDE somewhat like Microsoft Office Word for me as I write this book. While I could have written it using Notepad, using Word provides significant advantages. It assists in checking for spelling errors and allows me to easily add and visualize layouts, among other helpful features. This analogy paints a picture of how an IDE doesn’t just provide a platform to write code but also offers a suite of tools to streamline and enhance your coding experience.
Choosing an IDE
When it comes to Java development, there are several IDEs available, each with its own set of features and capabilities. In this section, we will discuss the factors to consider when choosing an IDE and help you set up some popular Java IDEs. Throughout this book, we’ll be working with IntelliJ. Alternatives that are also great would be VS Code and Eclipse.
Factors to consider when choosing an IDE
Most modern IDEs have features such as code completion, debugging, version control integration, and support for third-party tools and frameworks. Some of them have better versions of these than others. Compare and contrast what you prefer when choosing or switching IDEs.
Some IDEs require a heavier system to run on than others. For example, VS Code is rather lightweight and IntelliJ is rather heavy. Also, VS Code can be used for many languages, including Java. It is uncommon to do a lot of other things with IntelliJ rather than Java. Choose an IDE that provides a balance between features and performance, especially if you have limited system resources.
And of course, it’s possible that the IDE you’d prefer is not available for the platform you’re using. Make sure that it’s available and stable for your system.
Lastly, and very importantly, think about the costs. Some IDEs are free and others require a paid license. Luckily, many of the ones that require a paid license have a free edition for non-commercial use. So, make sure to also consider your budget and the licensing you need when choosing an IDE.
In the following subsections, we’ll walk you through the steps of setting up the three (currently) most common IDEs for Java development:
- IntelliJ
- Eclipse
- Visual Studio Code
Note
We’ll be working with IntelliJ for the rest of this book.
Setting up IntelliJ
So, let’s start with that one. IntelliJ IDEA is a popular Java IDE that was developed by JetBrains. It offers both a free Community Edition and a paid Ultimate Edition. It provides a wide range of features, including intelligent code completion, debugging tools, version control integration, and support for various Java frameworks.
Here are the steps for installing IntelliJ:
- Visit the IntelliJ IDEA download page at https://www.jetbrains.com/idea/download/.
- Choose the edition you prefer: the free Community Edition or the paid Ultimate Edition. For beginners, the Community Edition is truly great already.
- Download the installer for your operating system (Windows, macOS, or Linux).
- Run the installer and follow the instructions to complete the installation.
- Launch IntelliJ IDEA. If you’re using the Ultimate Edition, you may need to enter your JetBrains account credentials or a license key.
- On the Welcome screen, you can create a new project, import an existing project, or explore the available tutorials and documentation.
Setting up Eclipse
Eclipse is a free, open source Java IDE that is widely used in the Java community. It has been around for a really long time already and quite a lot of companies work with it still. It offers a variety of features, just like IntelliJ. Eclipse can be customized to suit your needs, but its interface may be less intuitive than other IDEs.
To set up Eclipse, follow these steps:
- Visit the Eclipse download page at https://www.eclipse.org/downloads/.
- Download the Eclipse installer for your operating system (Windows, macOS, or Linux).
- Run the installer and select Eclipse IDE for Java Developers from the list of available packages.
- Choose an installation folder and follow the instructions to complete the installation.
- Launch Eclipse and select a workspace directory. This is where your projects and settings will be stored.
- On the Welcome screen, you can create a new Java project, import an existing project, or explore the available tutorials and documentation.
Setting up Visual Studio Code
Visual Studio Code, often referred to as VS Code, is a lightweight, free, and open source code editor developed by Microsoft. It’s incredibly popular for all sorts of tasks because it supports a wide range of programming languages. It is a popular choice for developers who prefer a more minimalist and fast-performing environment. All sorts of additions can be added with the use of extensions.
Here are the steps for installing VS Code and preparing it for Java development:
- Visit the Visual Studio Code download page at https://code.visualstudio.com/download.
- Download the installer for your operating system (Windows, macOS, or Linux).
- Run the installer and follow the on-screen instructions to complete the installation.
- Launch Visual Studio Code.
- Open the Extensions view by clicking on the Extensions icon (four squares) on the left side of the window.
- Search for Java Extension Pack in the Extensions Marketplace and click the Install button. This extension pack includes various extensions for Java development, such as Language Support for Java (TM) by Red Hat, Debugger for Java, and Maven for Java.
- With the Java Extension Pack installed, you can now create or import Java projects. If it doesn’t load directly, you may need to reopen VS Code.
Now that you’ve set up an IDE, let’s create and run a program with it.