How to run .jar file on start up in ubuntu? - java

I have written a javafx media player.I want to run this on start-up. The mediaplayer.jar file is located at Desktop.The player plays the files inside a data folder which is in the same directory.

Thanks Raedwald.
I studied the post you mentioned and I finally resolved it.
Here the steps I did.
startapp.sh
#!/bin/bash
java -jar /home/usr/local/bin/vedioplayer.jar
created the above script and saved it in /etc/init.d
make sure you allow execution of the shell script.
sudo chmod +x /etc/init.d/startapp.sh
After that run the follwing command
sudo update-rc.d startapp.sh defaults 98 02
Also you can add the script to Startup Applications list from Applications.

Related

How to Run TestNG using Linux Shell file

I am using following working command for Windows batch file.
set projectLocation=E:\APPIUM\CXMFunctionalTest\LinuxAPITest
cd %projectLocation%
set classpath=%projectLocation%\bin;%projectLocation%\lib\*
java org.testng.TestNG %projectLocation%\testng.xml
pause
How i can convert this into Linux Shell Script? So i can run it in Linux machine.
cd /home/[[youruser]]/APPIUM;
java org.testng.TestNG /home/[[youruser]]/APPIUM/testng.xml;
This should be sufficient, considering that [[youruser]] is your users home folder, and the APPIUM folder is placed directly inside it. Then you can put this in a file called runappium.sh, and run it with the command sh appium.sh or mark it executable and run it directly.

Cannot run script/Java program on Raspberry Pi 3B boot

I'm simply trying to make a program run when the Raspberry boots up. The idea being it runs, so there is no need for a mouse/keyboard to manually start the program.
I've read forum after forum on how to run a script on boot on a Raspberry Pi. I feel like I've exhausted every method.
I have tried:
scheduling a cronjob
sudo crontab -e and then added the code
#reboot /file/path/myscript/
Putting my progam in the /etc/init.d/ folder and updating it in the boot sequence.
file moved to /etc/init.d/myscript/
make executable sudo chmod 755 /etc/init.d/myscript/
register script sudo update-rc.d defaults
Adding it to the .bashrc folder in the /pi directory
navigated to /home/pi/.bashrc/
added ./myscript/ to the file.
None of these have worked for me, whereas for everyone else on those forums, it seems to have solve their problem. Is there something I'm missing from any of these methods?

How to launch a jar file on windows startup from the registry?

I am trying to launch a jar file on Windows Server 2008 R2 startup.
I tried to add a key\value to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
I tried as a value several alternatives:
java -jar c:\jcm\jcm.jar
"java -jar c:\jcm\jcm.jar"
c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar
"c:\program files(x86)\java\jre1.8.31\bin\java.exe -jar c:\jcm\jcm.jar"
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
But none of them launched the program.
Can you advise please?
EDIT: Fixed exe to jar of course
You probably have a problem in the command line. I think it should be something like that last row that you have used but with jar and not exe.
"c:\program files(x86)\java\jre1.8.31\bin\java.exe" -jar c:\jcm\jcm.jar
You just need to test it in command line first and if it works it will work in the registry. You can also make a .bat file to start the java program and copy that to windows Startup Folder instead of using the registry.
The startup folder you can find here:
http://windows.microsoft.com/en-us/windows/run-program-automatically-windows-starts#1TC=windows-7
If it is Windows 10 then you may try this way-
Create a batch file e.g. (my-batch.bat with below statements.)
#echo off
title my-app batch script!
echo my-app welcomes you!
:: If your JAR contains GUI then use-
start javaw -Xmx200m -jar D:\Softwares\JAR\my-app-v1.0.jar
:: Otherwise use-
start java -jar D:\Softwares\JAR\my-app-v1.0.jar
Copy this my-batch.bat file at
C:\Users\pc\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Restart your PC to execute your JAR on startup.
Now, You may check your running JAR using Command Prompt with below commands-
1. jps -l
Output will look like-
8120 sun.tools.jps.Jps
13276 D:\Softwares\JAR\my-app-v1.0.jar
2. tasklist /V

Running Script on Startup

Essentially what I'd like to achieve is add a .jar file to the startup of my Linux computer. I created a script that would run the file and then tried adding that script to run when the system boots up.
I have a .java file on my desktop named Box.java. The file contains no errors and I manually compiled it and it was working fine. I then created a script on my desktop called start.sh and it's contents are
#!/bin/bash
javac /home/maple/Desktop/Box.java
So what this should do is compile the java class and the result would be a class file on my desktop called Box.class
I then created a file in /etc/init.d/ and it is called **start_java* it's contents are
#!/bin/sh
home/maple/Desktop/start.sh
I then opened up terminal and did
chmod +x /etc/init.d/start_java
I know the sh file will compile a java file and not run a file, in the completed copy I will be doing it with a jar file. How can I add that jar to startup without using a 3rd party software or any pre-installed programs?
EDIT: The current way I have it is not working.
You just want to do the same thing you already did, but changing the content of start.sh to:
#!/bin/bash
java -jar <filename>

How to install a software and then run java class from batch file

I have a batch file which runs a java class file.
But I want to install a software before running the class file?
When he runs batch file again then it should not ask for installing the software again.
file.bat
#echo off
cd ACR122U_MSI_Winx64_1120_P
Setup.exe
java -cp zpay-client-1.5-jar-with-dependencies.jar;.\resources com.abc.posgui.LicenseValidator
But this asks to install software everytime and does not execute java class. Any help would be appreciated.
If the Java doesn't work have you tried to launch the batch without "Setup.exe"?
#echo off
cd ACR122U_MSI_Winx64_1120_P
REM Setup.exe
java -cp zpay-client-1.5-jar-with-dependencies.jar;.\resources com.abc.posgui.LicenseValidator
Otherwise, are you sure that the installation has stopped?

Categories