Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Java on Mac

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to install Java on Mac". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

MacOS users can run an open source version of Java, as well as a new framework for cloud native cloud native development.

At the end of May, Java celebrated its 25th anniversary, and developers around the world used the hashtag # MovedByJava to share their achievements, memories and vision of using the programming language.

My timeline:

My timeline: 1999 start learning Java 2007 create @ grailsframework 2008 co-create G20ne 2009 acquired by SpringSource 2015 join @ ObjectComputing 2018 create @ micronautfw / win @ groundbreakers Award 2019 become @ Java_Champions Thank you @ java! # MovedByJava-Graeme Rocher (@ graemerocher) 21 May 2020

Over the years, many technologies and trends have promoted the development, deployment, and ability to run multiple applications on the Java stack on standard application servers. Building a container image for Kubernetes allows Java developers to package and deploy micro-service microservices in multiple cloud environments instead of running several application servers on virtual machines.

Timeline of technology contributions to Java

With these technologies, the Java application stack is optimized to run a larger heap and a highly dynamic framework that can make decisions at run time. Unfortunately, these efforts are not enough to make Java the programming language of choice for developers to develop cloud native cloud native Java applications for serverless serverless and event-driven platforms. Other languages have filled this gap, especially JavaScript, Python and Go, while Rust and WebAssembly have become new choices.

Despite this competition, cloud native Javacloud native Java is having an impact on cloud-centric software development. Fortunately, new Java frameworks (such as Quarkus, Micronaut, and Helidon) have recently overcome these challenges by providing faster and smaller applications with distributed systems in mind at the beginning of their design.

How to install Java on macOS

The future of Java development will start with more people installing and using Java. Therefore, I will show you how to install and start using the Java development environment on macOS. (if you are running Linux, please check out Seth Kenlon's article "how to install Java on Linux")

Install OpenJDK through the Brew repository

Homebrew is the de facto standard package manager for macOS. If you haven't already installed, Matthew Broberg's article "introduction to Homebrew" will take you through these steps.

When you have installed Homebrew on Mac, use the brew command to install OpenJDK, which is an open source way to write Java applications:

$brew cask install java

You can see it in less than a minute:

Java was successfully installed!

Verify that OpenJDK is installed correctly with the java-version command:

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

You can confirm from the output that OpenJDK 14 (the latest version at the time of this writing) is installed.

Install OpenJDK from binaries

If you are not keen on package managers and prefer to manage Java yourself, you can always choose to download and install it manually.

I found the download link for the latest version on the OpenJDK home page. Download the binaries for OpenJDK 14:

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

Move to the directory where you saved the binaries, and then extract:

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

Next, add Java to your PATH:

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

At the same time, add this command to your dot file, .zshrc or .zshrc depends on the shell you are running. You can learn more about configuring the $PATH variable in "how to set your PATH variable in Linux] [23]" in the article about configuring the `PATH variable] [23] ".

Finally, verify your installation of OpenJDK 14:

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

Write your first microservice microservices on Mac

Now you are ready to use the OpenJDK stack on maxOS to develop cloud native cloud native Java applications. In this tutorial, you will create a new Java project on Quarkus that uses dependency injection dependency injection to expose REST API.

You need Maven startup, which is a very popular Java dependency manager. Install it from Maven's website, or use the brew install maven command through Homebrew.

Execute the following Maven command to configure the Quarkus project and create a simple web application:

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

Run this application:

$. / mvnw quarkus:dev

When the application is running, you can see this output:

_ / _ / / _ _ / / _ _ / / / < / / _ / /\--\ _\ _ / _ _ / _ _ / 2020-06-13 0003displacement 06413 INFO [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 1.5.1.Final) started in 1.125s. Listening on: 2020-06-13 00 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. 2020-06-13 00 Quarkus Main Thread 0315 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy]

Use the curl command to access the REST endpoint:

$curl-w "\ n" http://localhost:8080/hello hello

Congratulations! By using Mavan and Quarkus, you quickly create your first web application in an environment that doesn't have Java installed.

This is the end of "how to install Java on Mac". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report