How to Set Up Your Environment to Start Java Development

Java Development (13 Part Series)

1 Getting Back to Java: A Journey Through One of the Most Versatile Languages
2 How to Set Up Your Environment to Start Java Development
9 more parts…
3 IntelliJ IDEA on Ubuntu: Begin Your Journey into Java Development!
4 Your First Java Project in IntelliJ IDEA: Creating a “Hello World” in Java
5 Exploring Classes and the Main Method in Java
6 Exploring Class Organization with Packages in Java
7 Variables and Data Types in Java
8 Understanding float and double in Java
9 Types: char and boolean
10 Exploring Non-Primitive Types in Java: A Dive into Object-Oriented Programming
11 Understanding Strings and Arrays in Java
12 Exploring the for Loop in Java
13 Exploring While and DoWhile in Java: Master Loop Structures with Practical Examples

If you’re here, you’re likely looking to learn how to set up your environment for Java development. The first step is to install the SDK (Software Development Kit), a set of tools and libraries provided by hardware and software vendors.

For Java, we use the JDK (Java Development Kit). The JDK is a collection of utilities that enable you to build applications for the Java platform. It includes a compiler, libraries, and essential tools. Keep in mind that Java is not just a programming language but also a platform. One of its key advantages is platform independence, meaning your programs can run on any compatible system.

Now that you know what we’ll be installing and its purpose, let’s get started!

Step 1: Update System Packages

Before anything else, ensure your system packages are up to date. Run the following command in your terminal:

sudo apt-get update && sudo apt-get upgrade

Enter fullscreen mode Exit fullscreen mode

Step 2: Install OpenJDK 17

The OpenJDK is a free, open-source implementation of Java. To install it, use this command:

sudo apt install openjdk-17-jdk

Enter fullscreen mode Exit fullscreen mode

Step 3: Check Installed Versions

If you have multiple Java versions installed, you’ll need to set one as the default. To list all installed versions, run:

sudo update-java-alternatives --list

Enter fullscreen mode Exit fullscreen mode

The output will look something like this:

java-1.17.0-openjdk-amd64      1711       /usr/lib/jvm/java-1.17.0-openjdk-amd64

Enter fullscreen mode Exit fullscreen mode

If only one version is listed (a single line), you can skip the next step. Otherwise, you’ll need to set OpenJDK 17 as the default.

Step 4: Set the Default Version

To configure OpenJDK 17 as the default version, use the command below, replacing the name with the path shown in your output:

sudo update-java-alternatives --set java-1.17.0-openjdk-amd64

Enter fullscreen mode Exit fullscreen mode

Step 5: Verify the Installation

Finally, check if everything is working correctly. To verify the installed Java version, run:

java -version

Enter fullscreen mode Exit fullscreen mode

You should see an output similar to this:

openjdk version "17.0.8.1" 2023-08-24  
OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)  
OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu122.04, mixed mode, sharing)

Enter fullscreen mode Exit fullscreen mode

Also, confirm the compiler version, which should match the runtime version:

javac -version

Enter fullscreen mode Exit fullscreen mode

You’re now ready to start developing in Java! In tomorrow’s post, I’ll guide you step by step on how to install IntelliJ IDEA, one of the most popular Integrated Development Environments (IDEs) for Java development. See you then!

Java Development (13 Part Series)

1 Getting Back to Java: A Journey Through One of the Most Versatile Languages
2 How to Set Up Your Environment to Start Java Development
9 more parts…
3 IntelliJ IDEA on Ubuntu: Begin Your Journey into Java Development!
4 Your First Java Project in IntelliJ IDEA: Creating a “Hello World” in Java
5 Exploring Classes and the Main Method in Java
6 Exploring Class Organization with Packages in Java
7 Variables and Data Types in Java
8 Understanding float and double in Java
9 Types: char and boolean
10 Exploring Non-Primitive Types in Java: A Dive into Object-Oriented Programming
11 Understanding Strings and Arrays in Java
12 Exploring the for Loop in Java
13 Exploring While and DoWhile in Java: Master Loop Structures with Practical Examples

原文链接:How to Set Up Your Environment to Start Java Development

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容