User Tools

Site Tools


transmission_of_audio_and_video:audio_and_video

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
transmission_of_audio_and_video:audio_and_video [2024/10/23 20:27] apereztransmission_of_audio_and_video:audio_and_video [2025/12/25 20:42] (current) aperez
Line 10: Line 10:
  
 {{ :transmission_of_audio_and_video:vlcli.png?600 |}} {{ :transmission_of_audio_and_video:vlcli.png?600 |}}
 +
 +{{ :transmission_of_audio_and_video:visionlite.png?800 |}}
 +----
 +
 +
 +
 +
 +
 +====== Automatic Startup of Java Application (VisionLite) as a Windows Service ======
 +
 +===== Purpose =====
 +Establish a standard, reproducible, and best-practice-aligned procedure to run a Java (.jar)
 +application as a **Windows Service**, ensuring:
 +
 +  * Automatic startup when the server boots
 +  * Independence from user login
 +  * Automatic restart on failures
 +  * Use of standard production paths
 +
 +---
 +
 +===== Scenario =====
 +Java application manually executed with:
 +
 +<code>
 +java -jar VLite_2_3_169.jar
 +</code>
 +
 +Requirement:
 +The application must start automatically after every operating system reboot.
 +
 +---
 +
 +===== Requirements =====
 +  * Windows Server 2016+ / Windows 10+
 +  * PowerShell with administrative privileges
 +  * Internet connectivity (initial installation)
 +  * Java Runtime Environment (JRE)
 +  * NSSM (Non-Sucking Service Manager)
 +
 +---
 +
 +===== Step 1 — Chocolatey Installation =====
 +Chocolatey is the standard Windows package manager.
 +
 +==== Verification ====
 +<code powershell>
 +choco -v
 +</code>
 +
 +==== Installation (if not present) ====
 +<code powershell>
 +Set-ExecutionPolicy Bypass -Scope Process -Force
 +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
 +iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
 +</code>
 +
 +Close and reopen PowerShell.
 +
 +---
 +
 +===== Step 2 — Java Installation and Verification =====
 +Java LTS is recommended (Java 8 or 11).
 +
 +==== Java 8 Installation ====
 +<code powershell>
 +choco install jre8 -y
 +</code>
 +
 +==== Verification ====
 +<code powershell>
 +java -version
 +</code>
 +
 +Validated output in this environment:
 +<code>
 +java version "1.8.0_261"
 +</code>
 +
 +---
 +
 +===== Step 3 — Identifying the REAL Java Path =====
 +⚠️ Do NOT use the wrapper:
 +<code>
 +C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
 +</code>
 +
 +==== Validate the real binary ====
 +<code powershell>
 +Test-Path "C:\Program Files\Java\jre1.8.0_261\bin\java.exe"
 +</code>
 +
 +Result:
 +<code>
 +True
 +</code>
 +
 +Confirmed path:
 +<code>
 +C:\Program Files\Java\jre1.8.0_261\bin\java.exe
 +</code>
 +
 +---
 +
 +===== Step 4 — NSSM Installation =====
 +NSSM allows applications to run as controlled Windows services.
 +
 +==== Installation ====
 +<code powershell>
 +choco install nssm -y
 +</code>
 +
 +==== Verification ====
 +<code powershell>
 +nssm version
 +</code>
 +
 +---
 +
 +===== Step 5 — Service Verification =====
 +Check whether the service already exists:
 +
 +<code powershell>
 +Get-Service *vision* | Format-Table Name,DisplayName,Status
 +</code>
 +
 +Validated result:
 +<code>
 +Name        DisplayName   Status
 +VisionLite VisionLite    Stopped
 +</code>
 +
 +---
 +
 +===== Step 6 — VisionLite Service Configuration =====
 +All commands must be executed in **PowerShell as Administrator**.
 +
 +==== Java executable definition ====
 +<code powershell>
 +nssm set VisionLite Application "C:\Program Files\Java\jre1.8.0_261\bin\java.exe"
 +</code>
 +
 +==== Execution parameters ====
 +<code powershell>
 +nssm set VisionLite AppParameters "-jar VLite_2_3_169.jar"
 +</code>
 +
 +==== Initial working directory ====
 +<code powershell>
 +nssm set VisionLite AppDirectory "C:\Users\Administrator\Desktop\Software"
 +</code>
 +
 +==== Automatic startup ====
 +<code powershell>
 +nssm set VisionLite Start SERVICE_AUTO_START
 +</code>
 +
 +==== Automatic restart on failure ====
 +<code powershell>
 +nssm set VisionLite AppExit Default Restart
 +nssm set VisionLite AppRestartDelay 60000
 +</code>
 +
 +---
 +
 +===== Step 7 — Service Start and Validation =====
 +<code powershell>
 +nssm start VisionLite
 +sc query VisionLite
 +</code>
 +
 +Validated state:
 +<code>
 +STATE : 4  RUNNING
 +</code>
 +
 +==== Auto-start confirmation ====
 +<code powershell>
 +sc qc VisionLite
 +</code>
 +
 +Result:
 +<code>
 +START_TYPE : 2  AUTO_START
 +</code>
 +
 +---
 +
 +===== Step 8 — Best Practice Correction =====
 +A user Desktop–based path is **NOT recommended** for production.
 +
 +==== Standard path defined ====
 +<code>
 +C:\Services\VisionLite
 +</code>
 +
 +---
 +
 +===== Step 9 — Service Migration to Standard Path =====
 +
 +==== Stop the service ====
 +<code powershell>
 +nssm stop VisionLite
 +</code>
 +
 +==== Create production directory ====
 +<code powershell>
 +mkdir C:\Services\VisionLite
 +</code>
 +
 +==== Migrate application files ====
 +<code powershell>
 +Move-Item "C:\Users\Administrator\Desktop\Software\*" "C:\Services\VisionLite\" -Force
 +</code>
 +
 +==== Update service working directory ====
 +<code powershell>
 +nssm set VisionLite AppDirectory "C:\Services\VisionLite"
 +</code>
 +
 +==== Restart the service ====
 +<code powershell>
 +nssm start VisionLite
 +sc query VisionLite
 +</code>
 +
 +---
 +
 +===== Step 10 — Final Validation =====
 +==== NSSM configuration dump ====
 +<code powershell>
 +nssm dump VisionLite
 +</code>
 +
 +Confirm:
 +<code>
 +AppDirectory C:\Services\VisionLite
 +</code>
 +
 +==== Recommended test ====
 +Reboot the server and verify the service is in RUNNING state.
 +
 +---
 +
 +===== Daily Operations =====
 +<code powershell>
 +nssm start VisionLite
 +nssm stop VisionLite
 +nssm restart VisionLite
 +sc query VisionLite
 +</code>
 +
 +---
 +
 +===== Troubleshooting =====
 +^ Symptom ^ Probable cause ^ Corrective action ^
 +| Service stops | Incorrect directory | Verify AppDirectory |
 +| JAR does not start | Incorrect Java path | Validate real java.exe |
 +| Does not start after reboot | Not AUTO_START | Verify sc qc |
 +| Files not found | Relative paths | Use standard path |
 +
 +---
 +
 +===== Best Practices =====
 +  * Use `C:\Services` or `C:\ProgramData`
 +  * Avoid user-profile-dependent paths
 +  * Document changes in Wiki
 +  * Centralize management with NSSM
 +  * Consider a dedicated service account for critical services
 +
 +---
 +
 +===== Final Note =====
 +Once configured as a service:
 +
 +❌ DO NOT manually execute:
 +<code>
 +java -jar VLite_2_3_169.jar
 +</code>
 +
 +✅ Manage exclusively as a Windows service.
 +
 +---
 +
 +<code powershell>
 +nssm stop VisionLite
 +sc query VisionLite
 +
 +nssm set VisionLite Application "C:\Program Files\Java\jre1.8.0_261\bin\java.exe"
 +nssm set VisionLite AppParameters "-jar VLite_2_3_169.jar"
 +nssm set VisionLite AppDirectory "C:\Services\VisionLite"
 +nssm set VisionLite Start SERVICE_AUTO_START
 +nssm set VisionLite AppExit Default Restart
 +nssm set VisionLite AppRestartDelay 60000
 +
 +nssm start VisionLite
 +sc query VisionLite
 +
 +sc qc VisionLite
 +
 +nssm dump VisionLite
 +
 +nssm start VisionLite
 +nssm stop VisionLite
 +nssm restart VisionLite
 +sc query VisionLite
 +</code>
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
  
transmission_of_audio_and_video/audio_and_video.1729715246.txt.gz · Last modified: by aperez

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki