Prepare Java development environment with VS Code


When developing Java with VS Code, it is useless if you do not set anything. There are many articles that only introduce Java to the point where it can be used even if you search on the net, so I would like to introduce the contents that should be set for those who want to develop Java in a strict manner.


-Java Extension Pack must be installed

Plugin installation

There is an installer for developing Java with VS Code, but this is not enough. There are other useful ones, so I will introduce them.

Creating a formatter definition file

There is a place to specify Java formatter in VS Code, but you can specify URL or local file path. Since I want to customize this time, I will first create my own formatter. It is possible to create a definition file as a text file, but since there is also a preview on the GUI, I will use Eclipse this time.

(1) Start Eclipse and open [Preferences]. (2) Select [Java]-[Code Style]-[Formatter]. (3) Click the [New] button. (4) Enter an arbitrary name (here, "My Formatter") in [Profile name] and click the "OK" button. (5) Make the following format settings.

category item value
Indentation Tab policy spaces only
Line Wrapping Never join already wrapped lines check

(6) After completing the settings, click the "OK" button. (7) Select the one created above (MyFormatter) from [Active Profile] and click the [Export All] button to save it locally. The file name to save is "formatter.xml".

Summary of setting values

VS Code settings

Open [Settings] and configure the following settings.

item Set value
Editor: Detect Indentation no check
Editor: Format On Save check
Java › Format › Settings: Url /path/to/formatter.xml
Java › Format › Settings: Profile MyFormatter
Java › Save Actions: Organize Imports check

Summary of setting values

in conclusion

At a minimum, you have an environment where you can develop Java. If you have any other opinions that you should do this, I would appreciate it if you could let me know.

Recommended Posts

Prepare Java development environment with VS Code
Build a Java development environment with VS Code
Prepare Java development environment with Atom
Java development environment (Mac, 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
[Environment construction] Build a Java development environment with VS Code!
Java web application development environment construction with VS Code (struts2)
Introduction to Java development environment & Spring Boot application created with VS Code
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Build Java program development environment with Visual Studio Code
Java Spring environment in vs Code
Java build with mac vs code
Java development environment
Build WebAPP development environment with Java + Spring with Visual Studio Code
Let me do VS Code Remote Development + Java development in Proxy environment
Lombok with VS Code
Java development environment memo
java development environment construction
Prepare the JVM language development environment with WSL
Using Gradle with VS Code, build Java → run
Prepare a scraping environment with Docker and Java
Create Spring Boot environment with Windows + VS Code
Try debugging a Java program with VS Code
A record of setting up a Java development environment with Visual Studio Code
Build VS Code + WSL + Java + Gradle environment from scratch
Docker management with VS Code
Build ruby debug environment with VS Code of Windows 10
Format Ruby with VS Code
Introduce JavaFX 15 and do GUI development with VS Code
Hello World with VS Code!
Prepare Python3 environment with CentOS7
Java development environment (Mac, Eclipse)
Prepare the environment for java11 and javaFx with Ubuntu 18.4
Beginners create Spring Tools Suite environment with VS Code
Java + Spring development environment construction with VirtualBox + Ubuntu (Xfce4)
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
The procedure I did when I prepared the environment of gradle + Java with VS Code (Windows 10)
I tried to create a java8 development environment with Chocolatey
A memo to start Java programming with VS Code (2020-04 version)
[Vagrant] Prepare LAMP development environment with Vagrant (centos + apache + MySQL + PHP)
[Java development environment construction] Install OpenJDK 11 (Java 11) on macOS with Homebrew.
[Eclipse Java] Development environment setting memo
Code Java from Emacs with Eclim
Play Framework 2.6 (Java) development environment creation
Java 15 implementation and VS Code preferences
Spring Boot programming with VS Code
About the current development environment (Java 8)
Build Java development environment (for Mac)
Execute packaged Java code with commands
Build jooby development environment with Eclipse
Html5 development with Java using TeaVM
Getting Started with Docker with VS Code
Install Java development environment on Mac
[Note] A story about changing Java build tools with VS Code
Settings to delete unused Java imports when saving with VS Code
Building a haskell environment with Docker + VS Code on Windows 10 Home
[Be careful about changing the version of Xdebug! ] Create a development environment with Xdebug3 + docker + VS Code
[Processing x Java] Construction of development environment
Laravel development environment construction with Docker (Mac)