4

[EDIT: Typing cd CashAdv THEN ] Running java -jar /home/bigaisdgood1/CashAdv/CashAdv.jar in a terminal would run my program correctly and has no problems.

However, when I use that line of code in a .desktop shortcut as exec=java -jar /home/bigaisdgood1/CashAdv/CashAdv.jar, it would run, but not connect.

My Java program (CashAdv.jar) connects to Localhost by making a Connection String from a .txt file placed in the same folder.

I have a feeling it just doesn't see the .txt file, but I'm open to other possibilities.

  • I've recently tried putting the .txt file in the same folder as the shortcut, with no effect.
  • Exec=cd /home/bigaisdgood1/CashAdv/ && java -jar /home/bigaisdgood1/CashAdv/FindDir.jar is invalid, and returns an error when I use the shortcut.
2

Use the Path= parameter in your desktop file and Type=Application.

E.g.

Path=/home/bigaisdgood1/CashAdv
Type=Application

Path defines the working directory to run the program in, when entry of Type is Application.

| improve this answer | |
0

Make the shortcut/icon execute your application:

java -jar yourApplication.jar org.example.your.MainClass

I suppose, you need to add the precise location of the file, something like

#!/bin/sh
java -jar /home/fred/examp/Example234/Fredexample.jar
| improve this answer | |
  • A .desktop file is no shell script, so I don't see why you use an sh shebang here... – Byte Commander Oct 12 '15 at 10:21
  • Just making sure because I don't understand your suggestion. You want me to add my package stack, pointing it to the class that contains my public static void main() function? – dgood1 Oct 12 '15 at 11:20
  • Well, using the package stack and/or adding #!/bin/sh did not help. I did realize I may have entered the directory when I first used my terminal command. The answer as been edited to reflect this mistake. Thanks for trying. – dgood1 Oct 12 '15 at 23:23
  • I'm very sorry that it didn't help… Good luck! – Fred Drothost Oct 13 '15 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.