How to Auto-Start a JAR on Windows After Reboot
This guide explains how to place a JAR file on a Windows server, create a batch script that runs the JAR, and configure the Windows Startup folder so the application launches automatically after the system restarts.
Scenario: Deploy a JAR on a Windows server and ensure it runs automatically after the machine reboots.
Implementation steps:
Choose a directory to store the JAR, e.g., D:\www\kaoqinBack, and copy the JAR (e.g., bdkqgl.jar) there.
Verify the JAR runs without errors: java -jar bdkqgl.jar Create a text file (e.g., badao.txt) with the following content:
@echo "公众号:霸道的程序猿"
java -jar d:\www\kaoqinBack\bdkqgl.jarSave the file and rename its extension to .bat (e.g., badao.bat).
Double‑click the batch file to confirm it opens a command window, prints the text, and launches the JAR without errors.
Automatic startup configuration:
Open the Windows Startup folder, typically located at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp. If the folder is hidden, enable the display of hidden files.
If the folder does not exist (or is named in Chinese), create a StartUp (or equivalent) directory manually.
Copy the prepared badao.bat into this Startup directory.
After placing the batch file, Windows will execute it automatically on each boot, causing the JAR to start without manual intervention.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
The Dominant Programmer
Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
