banner



How To Install Java On Mac Os

In tardily May, Java celebrated its 25th anniversary, and to commemorate the occasion, developers around the world used the hashtag #MovedByJava to share their achievements, memories, and insights with the programming linguistic communication.

Over the years, many technologies and trends take contributed to the Java stack'southward development, deployment, and ability to run multiple applications on standard application servers. Building container images for Kubernetes enables Java developers to packet and deploy microservices in multiple cloud environments rather than running several application servers on virtual machines.

Timeline of technology contributions to Java

With these technologies, the Java application stack has been optimized to run larger heaps and highly dynamic frameworks that can make decisions at runtime. Unfortunately, those efforts weren't skilful plenty to brand Coffee the preferred programming linguistic communication for developers to implement cloud-native Java applications for serverless and event-driven platforms. Other languages filled in the space, particularly JavaScript, Python, and Go, with Rust and WebAssembly offer new alternatives.

Despite this contest, cloud-native Coffee is making an affect on cloud-centric software development. Luckily, new Java frameworks (due east.one thousand., Quarkus, Micronaut, and Helidon) have recently broken through the challenges by offer smaller applications that compile faster and are designed with distributed systems in mind.

How to install Java on macOS

This hereafter for Java development starts with more people installing and using Java. So I volition walk through installing and getting started with the Java development environs on macOS. (If yous are running Linux, please see Seth Kenlon's article How to install Java on Linux.)

Install OpenJDK from a Mash repository

Homebrew is the de-facto standard packet manager for macOS. If you haven't installed it yet, Matthew Broberg'due south Introduction to Homebrew walks you through the steps.

One time you accept Homebrew on your Mac, use the brew command to install OpenJDK, which is the open source fashion to write Coffee applications:

                                    $              brew cask              install              java                              

In just a few minutes, you will run across:

                      ?              java              was successfully installed!                              

Confirm that OpenJDK installed correctly with $ java -version:

          

$ coffee -version
openjdk version "14.0.i" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7 )
OpenJDK 64-Chip Server VM (build xiv.0.1+vii, mixed style, sharing

The output confirms OpenJDK fourteen (the latest version, as of this writing) is installed.

Install OpenJDK from a binary

If yous are not a fan of packet management and adopt managing Java yourself, there's ever the option to download and install it manually.

I found a download link to the latest version on the OpenJDK homepage. Download the OpenJDK xiv binary:

                                    $                            wget              https://download.java.net/coffee/GA/jdk14.0.one/664493ef4a6946b186ff29eb326336a2/              7              /GPL/openjdk-xiv.0.1_osx-x64_bin.tar.gz                  

Motility to the directory where you downloaded the binary file and extract information technology:

                                    $                            tar              -xf              openjdk-14.0.1_osx-x64_bin.tar.gz                  

Side by side, add Java to your PATH:

                                    $                            export              PATH=$PWD              /jdk-14.0.1.jdk/Contents/Domicile/bin:$PATH                              

As well, add this to the path to your dotfiles, .bash_profile or .zshrc depending on what crush you are running. You lot tin can learn more than near configuring the $PATH variable in How to prepare your $PATH variable in Linux.

Finally, verify your OpenJDK xiv installation:

          

$ java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+seven )
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed fashion, sharing)

Write your first Java microservice on a Mac

Now you are prepare to develop a cloud-native Java application with OpenJDK stack on macOS. In this how-to, you'll create a new Java project on Quarkus that exposes a Remainder API using dependency injection.

You will demand Maven, a popular Coffee dependency managing director, to kickoff. Install it from Maven'south website or using Homebrew with brew install maven.

Execute the post-obit Maven commands to configure a Quarkus projection and create a unproblematic web app:

          

$ mvn io.quarkus:quarkus-maven-plugin:i.five.1.Final:create \
-DprojectGroupId=com.example \
-DprojectArtifactId=getting-started \
-DclassName="com.example.GreetingResource" \
-Dpath="/howdy"
cd getting-started

Run the application:

                                    $              ./mvnw quarkus:dev                  

You will see this output when the awarding starts:

          

__  ____  __  _____   ___  __ ____  ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-06-13 00:03:06,413 INFO  [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 1.five.1.Terminal) started in 1.125s. Listening on: http://0.0.0.0:8080
2022-06-13 00:03:06,416 INFO  [io.quarkus] (Quarkus Main Thread) Contour dev activated. Live Coding activated.
2022-06-xiii 00:03:06,416 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy]

Access the Rest endpoint using the ringlet control:

          

$ curl -due west "\n" http://localhost:8080 /hi
hullo

Congratulations! You have apace gone from not fifty-fifty having Java installed to building your first web application using Maven and Quarkus.

What to do adjacent with Java

Java is a mature programming language that continues to grow in popularity through new frameworks designed for cloud-native application development.

If you are on the path toward building that time to come, you lot may exist interested in more practical Quarkus development lessons or other mod frameworks. No matter what you're edifice, the side by side step is configuring your text editor. Read my tutorial on Writing Java with Quarkus in VS Code, then explore what else yous tin practise.

Creative Commons LicenseThis work is licensed under a Creative Eatables Attribution-Share Akin 4.0 International License.

Source: https://opensource.com/article/20/7/install-java-mac

Posted by: alvaradogonell.blogspot.com

0 Response to "How To Install Java On Mac Os"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel