Table of contents
1. Start the jar package under Windows
Tips: When packaging, comment out all the contents of application.yml, then package, and then put application.yml and the packaged jar package in the same level directory, as shown in the figure. The jar package will read this application.yml when it starts.
-
Start the jar package in the foreground:
use java.exe to start the jar package, once the window is closed, the process will endjava -jar swagger.jar
-
Start the jar package in the background:
use javaw.exe to start the jar package, and will not print the log in the window, and will directly run the process in the background, close the window, and the process will continue to runjavaw -jar swagger.jar
Close the process: the jar package started in the background, directly open cmd in the directory where the jar package is located, and enter
taskkill -f -t -im javaw.exe
to close the jar process
-
Start the jar package script in the background (start.bat):
Of course, it is more convenient to use the script to start in the background, and the custom name is .bat@echo off start javaw -jar swagger.jar exit
-
Background shutdown jar package script (stop.bat):
custom name.bat@echo off taskkill -f -t -im javaw.exe exit
Note: The script should be placed in the same directory as the jar package, and closing the script will close all jar packages started in the background.
2. Set cmd encoding
Windows default encoding GBK (936)
Temporarily change the encoding of this cmd to UTF-8 (reopening will restore it to GBK):
chcp 65001
Permanently change cmd to UTF-8 encoding:
-
open registry
- Method 1: win + r:
regedit
- Method 2:
- Method 1: win + r:
-
Arrive in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor directory
-
Right click - New - String Value
Rename: autorun
-
Double-click to modify numeric data
-
Newly open cmd, all are 65001 —— UTF-8 encoding
3. UTF-8 encoding start jar package
Foreground start:
java -jar -Dfile.encoding=UTF-8 swagger.jar
Background start:
javaw -jar -Dfile.encoding=UTF-8 swagger.jar
Start the jar package script (start.bat) in the background:
@echo off
start javaw -jar -Dfile.encoding=UTF-8 swagger.jar
exit
Close the jar package script (stop.bat) in the background:
@echo off
taskkill -f -t -im javaw.exe
exit
Note: The script should be placed in the same directory as the jar package, and closing the script will close all jar packages started in the background.