[Improvement of Java development efficiency] DCEVM and HotSwapAgent reflect changes in source code without restarting

What's DCEVM

https://github.com/dcevm/dcevm http://hotswapagent.org/

A JVM extension for dynamically replacing code while Java is running. In combination with HotSwapAgent, it can ** reflect code changes without restarting the application **.

Since there is an IntelliJ plugin, I will write how to use it together

reference: https://github.com/dmitry-zhuravlev/hotswap-agent-intellij-plugin#dcevm-installation

Comparison with other Hot Swap tools

There are many ways to reflect source code changes without restarting Java

Hot swap function of IDEs such as Intellij and Eclipse

If there is no change in the class structure, it will be replaced dynamically. However, it cannot be replaced when there is a change (more methods, renamed, pricvate → public, etc.)

JRebel strongest. But the price is high

Spring Loaded (* Spring only)

Development has stopped

DCEVM + HotSwapAgent Can be replaced except for changes in parent class and interface

Installation method

reference: https://github.com/dmitry-zhuravlev/hotswap-agent-intellij-plugin#dcevm-installation

1. Install the JDK

DCEVM is not compatible with all versions of the JDK. Currently (May 22, 2018), the latest supported version is Java 8u152, so download and install this version of Java.

You can download it here. However, user registration is required to download past JDKs. http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

2. Install DCEVM

download

Download DCEVM-8u152-installer.jar from https://github.com/dcevm/dcevm/releases/.

Launch the installer

Start with administrator privileges

sudo java -jar DCEVM-8u152-installer.jar

Apply DCEVM to JDK

  1. Click ʻAdd instration directory ...` to open the JDK directory
  2. Select the JDK you opened in 1 and click ʻInstall DCEVM as altjvm` Source: https://github.com/dmitry-zhuravlev/hotswap-agent-intellij-plugin#dcevm-installation

Install HotSwap Agent plugin on IntelliJ

Screen Shot 2018-05-15 at 11.07.01.png (372.8 kB)

Search for " HotSwapAgent "and click Install. Restart IntelliJ after installation is complete

Change Java used in IntelliJ

Open FileProject Structure ..., clickNew ... JDK of Project SDK`, and select the JDK installed in ↑. Screen Shot 2018-06-08 at 0.12.25.png

Enable HotSwapAgent Plugin

PreferencesToolsHotSwapAgent Check the startup settings to enable HotSwap Agent Screen Shot 2018-06-07 at 23.51.28.png

By the way, make sure that Hot Swap is enabled Screen_Shot_2018-05-15_at_11_46_54.png (257.0 kB)

Complete!

When you start a Java application (start debugging), the HOTSWAP AGENT log appears. Screen Shot 2018-05-15 at 11.24.32.png (136.0 kB) If you change the code in this state and compile it, it will be reflected immediately without restarting the application.

--Compile by itself (: Command + Shift + F9 / ⊞: Ctrl + Shift + F9) --Compile all (: Command + F9 / ⊞: Ctrl + F9)

Recommended Posts

[Improvement of Java development efficiency] DCEVM and HotSwapAgent reflect changes in source code without restarting
Basic structure of Java source code
Discrimination of Enums in Java 7 and above
Sample source code for finding the least common multiple of multiple values in Java
Technology for reading Java source code in Eclipse
Basics of threads and Callable in Java [Beginner]