• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

create a desktop shortcut on linux

Hi,
How can I create a desktop shortcut to a script in the users dir from java?
would the easiest way be from using a runtime.exec("ln -s /home/user/script.sh");
If I have an .ico file that I want to use for the shortcut how can I set the shortcut to use it?

Thanks in advance,
Spunog
0
spunog
Asked:
spunog
  • 4
  • 2
  • 2
1 Solution
 
petmagdyCommented:
Better trick:

Create the required Short cut with ur hand first and open the short cut file with VI and see if it the file can be created programatically, if it has a clear format
0
 
spunogAuthor Commented:
Thing is I'm doing this as part of an install. FRom java, copy all the apps files to the user directrory and then create a shortcut in /home/user/Desktop. User shouldn't have to do anything.....
0
 
petmagdyCommented:
no I mean the shortcut is a file that can be programatically generated if it has known format, so thats why I asked u to do it manually first to know how it look like
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
spunogAuthor Commented:
Ok I get you now.
Files called : The Link.desktop
If I edit the file it looks like this:

[Desktop Entry]
Exec='/home/user/blah.sh'
Icon=exec
..
..

So If I create this file from java and write it to the users desktop , then hey presto. ???
0
 
sciuriwareCommented:
For KDE look at $HOME/Desktop/*.desktop
The file has the basename of the shortcut.
;JOOP!
0
 
sciuriwareCommented:
I hate slow lines ..................
0
 
spunogAuthor Commented:
Thanks a lot,

Spunog
0
 
spunogAuthor Commented:
I have a small problem with this.
when the file is written to /home/user/Desktop it contains the same text as the manualy created link. However it does not work and when I look at the properties the os doesn't know its a .desktop file......   any ideas ?
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now