Add JAR to startup with terminal window

Latest response

Hello all, i am fairly new to Linux, I've been reading a bit about how to add an application to the startup execution in RHEL. I found this:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-boot-init-shutdown-run-boot.html

But I would like for the application to open a terminal window automatically, is this possible? Any ideas?

I already have my JAR file...

Regards,
Hector

Responses

Hi Hector,

First of all, the documentation you refer to is for Red Hat Enterprise Linux 5 -- that's very old. Unless you have some very specific reason to run an old version of the system, you should install version 7.

As you say you want to open a terminal window, I assume you're asking about automatic startup in the graphical environment. In RHEL 7, applications that are automatically run on session start are configured through the following menu item: Applications -> System Tools -> Startup Applications.

There you click on "Add" a enter the required application. You say that you would like to have the application run in a terminal window. This is what your command should look like:

gnome-terminal -e java -jar your_jar_file

We're telling the session manager to start the gnome-terminal application (the default terminal emulator in RHEL 7) and to execute from it the java command with your JAR file.

If you need to set this up for all users on the system, see Adding an Autostart Application for All Users in the Desktop Migration and Administration Guide.

Hello Robert, thanks for your input. I've tried your suggestion, but the command does nothing, if i try it manually i get a message saying "Failed to parse arguments: Unknown option-jar", if i remove the -jar option, a terminal window opens but closes immediately.

Regards, Hector

Hi Hector,

Are you sure you're typing the command correctly? Try to run your Java application like this first:

java -jar file.jar

That's the normal way to run .jar files.

yes, that command works, just not with the gnome-teminal together...

So i tried the command: gnome-terminal --execute java -jar MyApplication.jar Which, at least manually, seems to work, but no matter the command, the startup applications doesn't seem to execute my command, so my application doesn't start...

Gentlemen,

Are you talking about the same thing?

@Hector: starting a java application at server reboot time which requires input from a terminal screen is not a way a system administrator would be happy with. It could cause a server to hang, as the input would have to be provided from the console screen.

@Robert: Does your option need a full desktop, or would it also work with a ssh session with X11 forwarding opening just a single application?

Kind regards,

Jan Gerrit Kootstra

Hi Jan,

As I wrote in my first reply, I assumed that Hector wanted to run his application in a GUI environment (he mentioned a terminal 'window').

So, yes, the method I described requires a full GNOME session. To autostart an application in a command-line environment, I'd use ~/.bash_profile or something similar.

Well, deleted the entry instead of editing, the command that worked is: gnome-terminal --execute java -jar myApplication.jar

Thanks for your help Robert

Jan, the application doesn't require input at the terminal screen, it's just for me a way of knowing my application is communicating with the devices i need it to. As my previous post says, i got it to work the way i needed with that command...

Regards, Hector

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.