Just as the title says, just do Hello World. It may be a good way to quickly get rid of the usual standard output issues. I’m going to make a web app in this environment from now on! I don’t recommend it to anyone. I think there are other articles such as IntelliJ IDEA, Eclipse + Pleiades, and environment construction with NetBeans, so please refer to that article. I definitely want to try it with VS Code! I think that only people can refer to it.
Operation confirmed environment
- macOS: Catalina 10.15.5
- VSCode: 1.45.1
- Java: Amazon Correto 11.0.7
If you already have Java, skip to “Including Java extensions in VS Code”.
Install SDK MAN!
SDKMAN! is a tool for managing multiple Java in the same environment. Install SDKMAN! referring to here. https://sdkman.io/install
If your Mac OS version is Catalina at the time of purchase, change the first curl as follows.
curl -s "https://get.sdkman.io" | zsh
The default shell on Mac from Catalina is zsh. I haven’t tried fish, so I’d like you to tell me if you know it.
Install your favorite Java with SDK MAN!
First, check the Java that can be installed with SDKMAN! by executing the following command.
sdk list java
Then, the output will be as follows. (As of 2020/6) If it is not output, SDKMAN! is not installed properly.
=================================================== ============================== Available Java Versions =================================================== ============================== Vendor | Use | Version | Dist | Status | Identifier - ------------------------------------------------- ------------------------------ AdoptOpenJDK | | 14.0.1.j9 | adpt | | 14.0.1.j9-adpt | | 14.0.1.hs | adpt | | 14.0.1.hs-adpt | | 13.0.2.j9 | adpt | | 13.0.2.j9-adpt | | 13.0.2.hs | adpt | | 13.0.2.hs-adpt | | 12.0.2.j9 | adpt | | 12.0.2.j9-adpt | | 12.0.2.hs | adpt | | 12.0.2.hs-adpt | | 11.0.7.j9 | adpt | | 11.0.7.j9-adpt | | 11.0.7.hs | adpt | | 11.0.7.hs-adpt | | 8.0.252.j9 | adpt | | 8.0.252.j9-adpt | | 8.0.252.hs | adpt | | 8.0.252.hs-adpt Amazon | >>> | 11.0.7 | amzn | installed | 11.0.7-amzn | | 8.0.252 | amzn | | 8.0.252-amzn | | 8.0.202 | amzn | | 8.0.202-amzn Azul Zulu | | 14.0.1 | zulu | | 14.0.1-zulu | | 13.0.3 | zulu | | 13.0.3-zulu | | 13.0.3.fx | zulu | | 13.0.3.fx-zulu | | 12.0.2 | zulu | | 12.0.2-zulu | | 11.0.7 | zulu | | 11.0.7-zulu | | 11.0.7.fx | zulu | | 11.0.7.fx-zulu | | 10.0.2 | zulu | | 10.0.2-zulu | | 9.0.7 | zulu | | 9.0.7-zulu | | 8.0.252 | zulu | | 8.0.252-zulu | | 8.0.252.fx | zulu | | 8.0.252.fx-zulu | | 8.0.232.fx | zulu | | 8.0.232.fx-zulu | | 8.0.202 | zulu | | 8.0.202-zulu | | 7.0.262 | zulu | | 7.0.262-zulu | | 7.0.181 | zulu | | 7.0.181-zulu BellSoft | | 14.0.1.fx | librca | | 14.0.1.fx-librca | | 14.0.1 | librca | | 14.0.1-librca | | 13.0.2.fx | librca | | 13.0.2.fx-librca | | 13.0.2 | librca | | 13.0.2-librca | | 12.0.2 | librca | | 12.0.2-librca | | 11.0.7.fx | librca | | 11.0.7.fx-librca | | 11.0.7 | librca | | 11.0.7-librca | | 8.0.252.fx | librca | | 8.0.252.fx-librca | | 8.0.252 | librca | | 8.0.252-librca GraalVM | | 20.1.0.r11 | grl | | 20.1.0.r11-grl | | 20.1.0.r8 | grl | | 20.1.0.r8-grl | | 20.0.0.r11 | grl | | 20.0.0.r11-grl | | 20.0.0.r8 | grl | | 20.0.0.r8-grl | | 19.3.1.r11 | grl | | 19.3.1.r11-grl | | 19.3.1.r8 | grl | | 19.3.1.r8-grl Java.net | | 15.ea.26 | open | | 15.ea.26-open | | 14.0.1 | open | | 14.0.1-open | | 13.0.2 | open | | 13.0.2-open | | 12.0.2 | open | | 12.0.2-open | | 11.0.2 | open | | 11.0.2-open | | 10.0.2 | open | | 10.0.2-open | | 9.0.4 | open | | 9.0.4-open SAP | | 14.0.1 | sapmchn | | 14.0.1-sapmchn| | 13.0.2 | sapmchn | | 13.0.2-sapmchn | | 12.0.2 | sapmchn | | 12.0.2-sapmchn | | 11.0.7 | sapmchn | | 11.0.7-sapmchn =================================================== ============================== Use the Identifier for installation: $ sdk install java 11.0.3.hs-adpt =================================================== ==============================
I have Amazon Corretto 11.0.7, so it’s Installed.
Below is an example of installing Corretto.
11.0.7-amzn to your favorite Identifier.
$ sdk install java 11.0.7-amzn
Let’s make sure that Java is installed properly!
$ java --version openjdk 11.0.7 2020-04-14 LTS OpenJDK Runtime Environment Corretto-220.127.116.11.1 (build 11.0.7+10-LTS) OpenJDK 64-Bit Server VM Corretto-18.104.22.168.1 (build 11.0.7+10-LTS, mixed mode)
If the installed Java is displayed, it is successful.
Put Java extension in VS Code
Launch VSCode and search for
Java in the extension search.
Select Java Extension Pack and install it.
Create a Java project
By inserting the extension, it is possible to create a Java project.
Open the command palette with
Shift + Command + P and enter Java.
There are various commands like this.
Java: Create Java Project.
Then, the following will be displayed.
In this article, I’m only thinking about putting out Hello World, so I choose
No build tools for now.
You will be asked where to create it, so create it in a directory of your choice and with a name you like.
Then you will see the following in the lower right corner of the screen.
I will say it again and again, but since I only do Hello World, please select
Never for now.
The project will then be created with this configuration.
If you select
App.java, the main method that outputs the desired HelloWorld is displayed. Click Run.
The wished Hello World is displayed!