LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to create a desktop shortcut to a JAR file? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-a-desktop-shortcut-to-a-jar-file-694885/)

jdruin 01-04-2009 10:31 AM

How to create a desktop shortcut to a JAR file?
 
Hello.

I have installed Paros Web Proxy successfully. I can run the program by going to the command line and entering:

Code:

java -jar paros.jar
I though to create a shortcut I could right click the desktop and create a launcher. The launcher asked for a command in which I put:

Code:

java -jar /full_path/paros.jar
The launcher does not work. I then tried to right click the paros.jar file and create a link. I dragged the link to the desktop. This did not work either.

I see the similarities to Vista, but since no version of Windows really tells you exactly what is happening when you create a shortcut, I have never thought much about them.

What is it I am missing?

kilgoretrout 01-04-2009 11:00 AM

Try creating a bash script to run the commands that launch your application and link to the script for your shortcut. By way of illustration, create a text file in your home directory called do_paros and put this text in it:

Code:

#!/bin/bash
java -jar /full_path/paros.jar

This will be your bash script. Make sure that the you start on the first line, first space with "#!/bin/bash". Now open a console and make do_paros executable by running:

$ chmod a+x do_paros

And test the script from the command line to make sure it opens your application by running:

$ ./do_paros

If that works OK, then close the console and try running the script by double clicking on the do_paros file and see if it launches the application. If that works, create a shorcut to do_paros on your desktop and it should work fine.

jdruin 01-04-2009 02:00 PM

This did not work either, but the good news is that the error produced by this method is the same as the errors from the methods I tried earlier. Here is the error:

Exception in thread "main" java.io.FileNotFoundException: db/parosdb.data (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:137)
at org.parosproxy.paros.model.FileCopier.copyLegacy(Unknown Source)
at org.parosproxy.paros.model.FileCopier.copy(Unknown Source)
at org.parosproxy.paros.model.Model.createAndOpenUntitledDb(Unknown Source)
at org.parosproxy.paros.model.Model.init(Unknown Source)
at org.parosproxy.paros.Paros.run(Unknown Source)
at org.parosproxy.paros.Paros.main(Unknown Source)

I think that because the shortcuts are not running in the paros folder, the paros program is looking for the file db/parosdb.data in the shortcuts directory rather than the paros directory.

I am not sure how to work around this though.

jdruin 01-04-2009 02:04 PM

OK. I edited the shortcut file to read:

#!/bin/bash
cd /home/ubuntu/programs/paros
java -jar paros.jar

This worked. I have been using windows for a decade so Linux is taking some getting used to. Thanks for the help.

tredegar 01-04-2009 03:55 PM

Quote:

cd /home/ubuntu/programs/paros
This is what made it work, because the "simple" shortcut you first created didn't specify the "working directory".
There might / should have been an option for you to do this ( there is in KDE ).
Now it's working, be happy.


All times are GMT -5. The time now is 09:08 AM.