Location>code7788 >text

java program to set boot-up

Popularity:366 ℃/2024-10-22 15:16:06

Linux system jar package boot self-start

Step 1: Create the service file
sudo nano etc/systemd/system/
Step 2: Copy the following code into the file you just created and save it
[Unit]

Description=Java camera service
After=

[Service]

WorkingDirectory=/home/app/java
Environment="LD_LIBRARY_PATH=/home/app/java/lib"
ExecStart=/opt/java8/bin/java -jar  /home/app/java/
Restart=no
User=Admin
RestartSec=30
StandardOutput=append:/home/app/java/
StandardError=append:/home/app/java/
Type=simple

[Install]

WantedBy=

WorkingDirectory: replace it with the location of your jar.

Environment: the environment on which the jar package should be started, if you have it, add it, if not, don't add it.

ExecStart: Specify the location of your jar package from the jdk's bin directory

Restart: Setting the restart method

User: the role that uses the device

RestartSec: how many times to restart the

StandardOutput, StandardError: Set the log location.

 

Win system boot up

  1. Open Notepad: Find the Notepad application in Windows and open it.
  2. Write a batch script: copy the following into Notepad and modify it to your actual path:
  3. @echo off
    javaw -jar "D:\app\"

    3. Save the file:

    1. Click on "File" > "Save As".
    2. Select a save location, such as the desktop.
    3. In the "File name" box, enterstart_apps.bat(Make sure the file extension is.bat)。
    4. Select "All files" for "Save as type".

    4. Set up boot-up:

    1. check or refer toWin + RInputshell:startup, then press Enter, which will open the startup folder.
    2. Place the just-createdstart_apps.bat file is copied to this startup folder.

    5. Restart your computer: After restarting, your JAR package and other programs should start automatically!