0

I stand for days on this simple problem. I must create a launcher on the Desktop for a jar application. The jar application is locate in a subdirectory of home user (/home/user/java). I want create a launcher on the Desktop.

The problem is that my jar application run a console application. Now, when I run the jar application from its position all is well but when I run the launcher icon on the desktop, the jar application run but not the console application.

I have created the launcher both as "Application" both as "Application Console"; I have putted in the "command line" the entire path (java -jar /home/user/java/program.jar); finally I have tried to create the launcher connected not at the jar application directly but a script shell that contains the command for run the program (java -jar /home/user/java/program.jar) but never. The strange thing is that the script shell, if it launched alone, works well but when it is launched from the launcher icon not.

This is the code of my launcher:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=gnome-panel-launcher
Name[en_US]=Testpad
Exec=java -jar /home/usertest/java/testpad.jar
Name=Testpad
Icon=gnome-panel-launcher

I have tried also to put in Exec=/home/usertest/java/script.sh where in the script there is:

#!/bin/bash

java -jar /home/usertest/java/testpad.jar

Where do I wrong? Thanks at all.

EDIT 1

I'm going crazy! Why if I run the script in the console it works well while if I run the same script with double click the java application run but don't work the p = Runtime.getRuntime().exec("testpad -i -c"+can+" -n"+pad+" "+pathFile); ?

Local Hero
  • 493
  • 2
  • 7
  • 20

3 Answers3

1

You should edit the line Terminal=false to Terminal=true, and then try it.

If it doesn't work edit it to open a terminal and run the command. Like this, yourTerminal -e command like,

xterm -e "java -jar /home/usertest/java/testpad.jar"

or

gnome-terminal -e "java -jar /home/usertest/java/testpad.jar"

or

konsole -e "java -jar /home/usertest/java/testpad.jar"

or

xfce4-terminal -e "java -jar /home/usertest/java/testpad.jar"
lpsandaruwan
  • 790
  • 2
  • 11
  • 27
  • Still no go, I tried this: #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=true Icon[en_US]=/home/usertest/java/PCB-icon.png Name[en_US]=Testpad Exec=gnome-terminal -e "java -jar /home/usertest/java/testpad.jar" Comment[en_US]=Testpad GUI Name=Testpad Comment=Testpad GUI Icon=/home/usertest/java/PCB-icon.png – Local Hero Jun 23 '15 at 12:27
  • 1
    Add some option to hold the terminal. Will work. Take a look at here, http://stackoverflow.com/questions/3512055/avoid-gnome-terminal-close-after-script-execution – lpsandaruwan Jun 23 '15 at 13:47
  • Still nothing :( I tried this gnome-terminal -e "bash -c \"echo foo; echo bar; exec bash\"" and with the script.sh but nothing :( I do not know what to do. It's impossible :( – Local Hero Jun 23 '15 at 14:58
  • I have added "source .bashrc" and now all works well! Thanks! – Local Hero Jun 24 '15 at 08:53
0

If you want add to frame or panel a console, I think this can help you: how to visualize console java in JFrame/JPanel

Community
  • 1
  • 1
SkySibe
  • 153
  • 1
  • 7
  • No, my problem is that I can't create the desktop icon on the desktop, the java program is completed and works well – Local Hero Jun 23 '15 at 06:46
0

Make sure java is in your system path.

If you have added java to PATH variable in .bashrc file it will be available to terminal session only.

If possible set update-alternatives links at /usr/bin/java

shanmuga
  • 4,329
  • 2
  • 21
  • 35