1. Windows regular startup jar package (external configuration file)
#java -jar jar_path.jar --spring.config.location=config_path
java -jar demo.jar --spring.config.location=application.properties
After startup, you can see the startup console information in the command box. If you close the command box, the program will also close.
2. The difference between java and javaw
The program run by the java command will have console output information, but javaw will not appear a console window, nor will it output any information.
3. Write start and stop scripts
Create a new startup.bat in the same directory as the jar package.
@echo off
start javaw -jar demo.jar --spring.config.location=application.properties
exit
Create a new shutdown.bat in the same directory as the jar package.
@echo off
taskkill -f -t -im javaw.exe
exit
4. Run and view ports and processes
Double-click startup.bat to start the jar program
Type netstat -ano in the cmd command box to view all port numbers, find the startup port corresponding to the jar configuration file, and find its PID
Open Task Manager--Process--Open the PID column and find the program corresponding to the PID, which is javaw.exe
Double-click shutdown.bat to close the jar program, and the corresponding port and process disappear.