Build a Java development environment with VS Code

Although I introduced object-oriented programming using Java in my undergraduate class, I will re-introduce it after reviewing it because "I forgot it a long time ago ...".

Development environment construction

I used Java in my undergraduate classes about two years ago, but since I'm using it for the first time after renewing my PC, I have to build a development environment. Eclipse is famous as an integrated development environment and was used in lectures. However, I didn't want to install it newly because of Java, which is used infrequently, so I built the environment using VS Code.

The environment was constructed with reference to here. The following is an outline of the environment construction written in the link.

Installation of JDK (Java SE Development Kit)

If you have not installed the JDK, you need to download it from the following.

VSCode for Java seems to be available in Java SE 11 and above, so you can download the latest JDK from the link above.

Be sure to make a note of the path when you install it, as you will set the path in the next step.

`` `java.home``` settings

This time, Java can be used only with VS Code, so it is enough to set `` `java.home``` of VS Code. The setting procedure is as follows:

  1. Open the VS Code settings screen (`Ctrl +,`)
  2. Enter "java.home" in the search box image.png
  3. Click Edit in settings.json and enter the path of the installed JDK in `` `java.home```

Example of path to set


{
...,
"java.home": C:\\Program Files\\Java\\jdk-13.0.2,
}

Java Extension Pack installation

Next, install multiple VS Code extensions that are famous for Java development at once. The procedure is as follows:

  1. Open the extension screen (`` `Ctrl + Shift + X```)
  2. Enter "java" in the search box image.png

You should now see the "Java Extension Pack" at the top. Press the Install button and wait for a while to complete. Now you have a Java environment using VS Code!

Create and run Java projects

A project is a collection of source files that make up the program to be developed and settings for compiling and executing them. Let's create a project right away.

Creating a Java project

  1. Open the command palette with Ctrl + Shift + P` `` or` `F1 and select Create Java Project` `` image.png

  2. Select ``` No Build Tools` `` as the project type image.png

  3. Select a folder

  4. Enter the name of the project (here `` `HelloWorld```) image.png

You have now created a project!

Run

When you create a project, some files will be created automatically as shown in the image below.

src/App.Looking at java, Hello by default, World!There is a program that outputs.


 ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/486404/2928068c-7593-1255-67ee-a4b2c96486dd.png)

 It says ``` Run | Debug``` above main.
 To run this program, just click on this `` `Run```.


#### **`Execution result`**
```java

Hello, World!

You have now created and run your project!

In a future article, I will introduce object-oriented programming while implementing rock-paper-scissors.

reference

Recommended Posts

Build a Java development environment with VS Code
[Environment construction] Build a Java development environment with VS Code!
Build Java development environment with VS Code on Mac
Build Java development environment with WSL2 Docker VS Code
How to build Java development environment with VS Code
Prepare Java development environment with VS Code
Java build with mac vs code
Java development environment (Mac, VS Code)
Build Java program development environment with Visual Studio Code
Build a PureScript development environment with Docker
Build a Java development environment on Mac
Java web application development environment construction with VS Code (struts2)
Build a Wordpress development environment with Docker
Build WebAPP development environment with Java + Spring with Visual Studio Code
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
[Note] A story about changing Java build tools with VS Code
Build a WordPress development environment quickly with Docker
Build a development environment for Docker, java, vscode
Try debugging a Java program with VS Code
A record of setting up a Java development environment with Visual Studio Code
Introduction to Java development environment & Spring Boot application created with VS Code
Build VS Code + WSL + Java + Gradle environment from scratch
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Build ruby debug environment with VS Code of Windows 10
Try to build a Java development environment using Docker
Build a Java project with Gradle
Java Spring environment in vs Code
Prepare Java development environment with Atom
Build Java development environment (for Mac)
Build jooby development environment with Eclipse
I tried to create a java8 development environment with Chocolatey
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
A memo to start Java programming with VS Code (2020-04 version)
Build Java 8 development environment on AWS Cloud9
Build a simple Docker + Django development environment
Let me do VS Code Remote Development + Java development in Proxy environment
Building a haskell environment with Docker + VS Code on Windows 10 Home
Build a development environment for Django + MySQL + nginx with Docker Compose
Steps to build a Ruby on Rails development environment with Vagrant
Build a development environment for Docker + Rails6 + Postgresql
Let's get started with Java-Create a development environment ②
Let's get started with Java-Create a development environment ①
Lombok with VS Code
Java development environment memo
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Build a Laravel / Docker environment with VSCode devcontainer
[Java] Build Java development environment on Ubuntu & check execution
Build a hot reload development environment with Docker-compose using Realize of Go
java build a triangle
Creating a java web application development environment with docker for mac part1
I tried to build a Firebase application development environment with Docker in 2020
Build an E2E test environment with Selenium (Java)
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
Build a simple Docker Compose + Django development environment
java development environment construction
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code
Create Spring Boot environment with Windows + VS Code
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Build a Java runtime environment on Sakura VPS
Build Java with Wercker