Setting up a launcher for a java app

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
Tartufo
Level 1
Level 1
Posts: 23
Joined: Tue Feb 05, 2013 5:50 am

Setting up a launcher for a java app

Post by Tartufo » Wed Oct 02, 2019 2:05 pm

Hi all

Mint 19.1 Mate desktop

I have a program that I would like to set up with a launcher from a panel. It is a program which relies on java 8 for its database.

At present, to launch it using the terminal, I cd into the folder

Code: Select all

cd ~/X/Y/Z
and then enter

Code: Select all

./Z.jar
and this launches it just fine.

However, I'd like to set up a nice icon for it in my applications drawer on my main panel in Mate. I've tried, in the properties options,

Code: Select all

cd ~/X/Y/Z && ./Z.jar
and also

Code: Select all

./home/me/X/Y/Z/Z.jar
but neither work.

Any other ideas I could try? The program has been given r,w,x permissions already.

Thanks in advance.

User avatar
JoeFootball
Level 7
Level 7
Posts: 1925
Joined: Tue Nov 24, 2009 1:52 pm
Location: /home/usa/mn/minneapolis/joe

Re: Setting up a launcher for a java app

Post by JoeFootball » Wed Oct 02, 2019 3:04 pm

Tartufo wrote: Any other ideas I could try?
Try...

Code: Select all

cd ~/X/Y/Z && java -jar Z.jar
Joe

User avatar
kyphi
Level 9
Level 9
Posts: 2627
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Setting up a launcher for a java app

Post by kyphi » Wed Oct 02, 2019 4:05 pm

To get a launcher for a Java program I would use a script to encapsulate the directory changes.

#-----------------------#
#!/bin/bash
cd /home/tartufo/location of program
java -jar program.jar
#-----------------------#

Please note "/home/tartufo" not "~"

Name and save the script and make it executable in Properties. Then use the path to the script when you create an entry for your main menu which will enable you to create a launcher on the panel.
Linux Mint 19.2 Cinnamon - 64bit

Tartufo
Level 1
Level 1
Posts: 23
Joined: Tue Feb 05, 2013 5:50 am

[SOLVED]Re: Setting up a launcher for a java app

Post by Tartufo » Thu Oct 03, 2019 12:35 pm

@Joe:
Thanks - I tried that, and that didn't work.

@kyphi:
That was the trick - thank you for that suggestion. The program is now triggered from my panel just like it I had wanted. Kudos!!

gm10
Level 19
Level 19
Posts: 9830
Joined: Thu Jun 21, 2018 5:11 pm

Re: Setting up a launcher for a java app

Post by gm10 » Thu Oct 03, 2019 12:47 pm

JoeFootball wrote:
Wed Oct 02, 2019 3:04 pm
Tartufo wrote: Any other ideas I could try?
Try...

Code: Select all

cd ~/X/Y/Z && java -jar Z.jar
Joe
That won't work in a launcher like that, you need to spawn a shell first:

Code: Select all

bash -c "cd ~/X/Y/Z && java -jar Z.jar"
But even better is just defining the working directly in the .desktop file using the Path= parameter, see: https://specifications.freedesktop.org/ ... atest.html
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

User avatar
kyphi
Level 9
Level 9
Posts: 2627
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Setting up a launcher for a java app

Post by kyphi » Fri Oct 04, 2019 3:32 am

@ Tartufo - I thank you for your acknowledgement and I am pleased that my suggestion accomplished your goal.
Linux Mint 19.2 Cinnamon - 64bit

Post Reply

Return to “Newbie Questions”