Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn Java with Projects

You're reading from   Learn Java with Projects A concise practical guide to learning everything a Java professional really needs to know

Arrow left icon
Product type Paperback
Published in Nov 2023
Publisher Packt
ISBN-13 9781837637188
Length 598 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Maaike van Putten Maaike van Putten
Author Profile Icon Maaike van Putten
Maaike van Putten
Dr. Seán Kennedy Dr. Seán Kennedy
Author Profile Icon Dr. Seán Kennedy
Dr. Seán Kennedy
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Part 1: Java Fundamentals
2. Chapter 1: Getting Started with Java FREE CHAPTER 3. Chapter 2: Variables and Primitive Data Types 4. Chapter 3: Operators and Casting 5. Chapter 4: Conditional Statements 6. Chapter 5: Understanding Iteration 7. Chapter 6: Working with Arrays 8. Chapter 7: Methods 9. Part 2: Object-Oriented Programming
10. Chapter 8: Classes, Objects, and Enums 11. Chapter 9: Inheritance and Polymorphism 12. Chapter 10: Interfaces and Abstract Classes 13. Chapter 11: Dealing with Exceptions 14. Chapter 12: Java Core API 15. Part 3: Advanced Topics
16. Chapter 13: Generics and Collections 17. Chapter 14: Lambda Expressions 18. Chapter 15: Streams – Fundamentals 19. Chapter 16: Streams: Advanced Concepts 20. Chapter 17: Concurrency 21. Index

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:

  1. Visit the IntelliJ IDEA download page at https://www.jetbrains.com/idea/download/.
  2. Choose the edition you prefer: the free Community Edition or the paid Ultimate Edition. For beginners, the Community Edition is truly great already.
  3. Download the installer for your operating system (Windows, macOS, or Linux).
  4. Run the installer and follow the instructions to complete the installation.
  5. Launch IntelliJ IDEA. If you’re using the Ultimate Edition, you may need to enter your JetBrains account credentials or a license key.
  6. 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:

  1. Visit the Eclipse download page at https://www.eclipse.org/downloads/.
  2. Download the Eclipse installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer and select Eclipse IDE for Java Developers from the list of available packages.
  4. Choose an installation folder and follow the instructions to complete the installation.
  5. Launch Eclipse and select a workspace directory. This is where your projects and settings will be stored.
  6. 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:

  1. Visit the Visual Studio Code download page at https://code.visualstudio.com/download.
  2. Download the installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer and follow the on-screen instructions to complete the installation.
  4. Launch Visual Studio Code.
  5. Open the Extensions view by clicking on the Extensions icon (four squares) on the left side of the window.
  6. 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.
  7. 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.

You have been reading a chapter from
Learn Java with Projects
Published in: Nov 2023
Publisher: Packt
ISBN-13: 9781837637188
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime