Not able to run the jar file during startup of system - linux

I have RedHat linux. Intention is to start the java based GUI app after linux system finishes boot up. I have edited /etc/rc.local and kept
/usr/java/jre1.7.0_60/bin/java -jar /home/rfgwtest/Desktop/CEM/CEM_v2.0_Beta08/CEM_v2.0_Beta08/PME_CEM.jar &
at the end of the file. I am able to run this file for testing by executing the file on prompt. no errors of path or so.
what is missing as part of this? i have found this tip from the RedHat website
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-boot-init-shutdown-run-boot.html
is there a common way to do this across the different kind of distribution ?

Maybe, creating a desktop entry will do it.
To do that,
$ cd
$ nano .config/autostart/javaApp.desktop
now, write this inside it,
[Desktop Entry]
Type=Application
Exec=usr/java/jre1.7.0_60/bin/java -jar /home/rfgwtest/Desktop/CEM/CEM_v2.0_Beta08/CEM_v2.0_Beta08/PME_CEM.jar
Hidden=false
NoDisplay=false
Name[en_IN]=StartJAR
Name=StartJAR
Comment[en_IN]=Jar comment
Comment=Jar comment
save the file and then, restart or re-login to the system.

Related

How to run a script on a terminal at startup?

I'm working on a project in which I'm using the Raspberry Pi 3B+ has the latest Raspbian GNU/Linux 10 (buster). At present, my code (shell script) is running in the crontab (with #reboot command). As we all know that the script added in the crontab runs in the background, hence, I can't see the debug messages it is printing. Therefore, I'm looking for a feature or function, which should be similar to the process in which I run the code in the terminal.
By doing some research online, I found many references related to this kind of requirements. The most common method was making a .desktop file and add into ~/.config/autostart
[Desktop Entry]
Exec=lxterminal -e "sudo sh /home/pi/Desktop/main_pro/keeper_sh.sh"
Type=Application
But unfortunately, there is no autostart folder in my ./config directory. could someone help me in achieving this task?

run external application in linux using qprocess

I am creating an GUI application using QT creater in Raspbian. When I click a button I want to open an external application like terminal, or browser, etc.
I have tried many attempts
attempt 1
std::system("/usr/share/raspi-ui-overrides/applications/scratch.desktop&");
it says me permission denied
attempt 2
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
this one is working but its not opening the application but its opening in terminal:
QDesktopServices::openUrl(QUrl("/usr/share/raspi-ui-overrides/applications/scratch.desktop"));
I'm assuming the question is about Raspberry Pi and Raspbian.
In Raspbian, the scratch.desktop and other *.desktop files are not executables, but just text files that describe which application to run.
Example:
pi#raspberrypi:~ $ cat /usr/share/raspi-ui-overrides/applications/scratch.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
TryExec=scratch
Exec=scratch
Icon=scratch
Terminal=false
Name=Scratch
Comment= Programming system and content development tool
Categories=Application;Development;
MimeType=application/x-scratch-project
You need to use an actual binary to start the process. For scratch, it would be /usr/bin/scratch. For a browser, it's likely to be /usr/bin/epiphany-browser. Look at Exec= line in the *.desktop file to see the name of the executable, then use which in the terminal to see its location:
pi#raspberrypi:~ $ which epiphany-browser
/usr/bin/epiphany-browser
The .desktop files are not executable, but serve as shortcuts for the desktop system. Assuming that the scratch.desktop has the following:
scratch.desktop
[Desktop Entry]
Name=Scratch
Comment= Programming system and content development tool
Exec=scratch
Terminal=false
Type=Application
Icon=scratch
Categories=Development;
MimeType=application/x-scratch-project
Then the executable is /usr/bin/scratch, And you can run it with Qt:
QProcess::startDetached("/usr/bin/scratch");
Or:
QProcess::execute("/usr/bin/scratch");

LXDE .desktop file permission issue

I’m trying to run a Python script via a desktop icon/shortcut/launcher on a Raspberry Pi using Raspbian and LXDE. I have to use a desktop launcher since the script has to be started via a tiny touchscreen only accepting left-clicks and without a keyboard.
I think that I have a permission issue since the script fails at a point where it should execute some system commands which require root.
The script works if I do the following:
Open a terminal
Enter sudo python3 program.py
I tried to replicate this behavior with a .desktop file using the following config:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=sudo python3 program.py
Terminal=true
Icon=path/to/icon.png
Name=Program Launcher
I suppose I missed something obvious, but since I don’t work with Linux usually I’m a bit lost here.
Edit: The problem was not a missing permission but an incorrectly assumed working directory and is now solved. Sorry for my confusion.
In detail: during development the script was started from its own folder while the desktop launcher used /home/pi as working directory. In general that's not a problem, but in the script a hardcoded path was used and a required file not found when using the launcher. The real problem was sloppy swallowed and the status code of a permission issue returned. So it was simply a bad code issue.
As docs for desktop entries says:
The Exec key must contain a command line. A command line consists of
an executable program optionally followed by one or more arguments.
The executable program can either be specified with its full path or
with the name of the executable only. If no full path is provided the
executable is looked up in the $PATH environment variable used by the
desktop environment. The name or path of the executable program may
not contain the equal sign ("="). Arguments are separated by a space.
It leads to conclusion, that maybe python3 is not within $PATH used by the desktop environment. Try to check full path of your python3 and sudo with:
whereis python3
whereis sudo
on my Archlinux it gives me /usr/bin/python3 and /usr/bin/sudo. Try to modify your Dekstop entry to something like:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=/usr/bin/sudo /usr/bin/python3 program.py
Terminal=true
Icon=path/to/icon.png
Name=Program Launcher
Let me know if this helps.

run jedit single command from terminal linux

I'm trying to run jedit from the terminal on fedora. its installed to the path /usr/local/share....
How do I get it to run "jedit" from the terminal rather than switching to the directory and typing java -jar jedit.jar to execute the program.
I created a sh file in that same direectory with "java -jar jedit.jar" and added that directory to ~/.bashrc. I'm aware that I need to type "sh file.sh" to run that file but I know there is a gap in my knowledge somewhere.
i want to use jedit as a commit editor for git and be able to change core.editor='jedit -w' in git config
someone please help
I assume you used the Java installer?
If this is the case, the installer should also have placed a jedit launch script in /usr/local/bin which should be in your PATH by default, so calling jedit from a terminal should instantly work after installation.
If it does not work, then please check whether the file jedit is available in /usr/local/bin and whether /usr/local/bin is in your PATH environment variable.

adding a start up via command line (Ubuntu)

Hey, I'm trying to have a graphical program and I want it to start after I log in. How do I do so? I know there's a GUI program, but I want to use a command line here.
GUI tool:
http://www.thegeekstuff.com/2009/07/ubuntu-open-applications-automatically-during-system-startup/
now, there is update-rc.d, however, it seems to run before I log in, while the entire system loads ups (Unless I don't understand what the NN means in the update-rc.d manual).
Any ideas?
There's also an autostart folder in ~/.config/autostart - which is profile (or user) specific. If you put a .desktop file in /etc/xdg/autostart it will become a global startup for any new users created. This assumes you have xdg-user-dirs-gtk installed.
Drop a .desktop file in... /etc/xdg/autostart here, might be different on Ubuntu.

Resources