Solved

create a desktop shortcut on linux

Posted on 2004-11-01
348 Views
Last Modified: 2012-05-05
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
Question by:spunog
    8 Comments
     
    LVL 13

    Expert Comment

    by:petmagdy
    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
     

    Author Comment

    by:spunog
    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
     
    LVL 13

    Accepted Solution

    by:
    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
     

    Author Comment

    by:spunog
    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
     
    LVL 24

    Expert Comment

    by:sciuriware
    For KDE look at $HOME/Desktop/*.desktop
    The file has the basename of the shortcut.
    ;JOOP!
    0
     
    LVL 24

    Expert Comment

    by:sciuriware
    I hate slow lines ..................
    0
     

    Author Comment

    by:spunog
    Thanks a lot,

    Spunog
    0
     

    Author Comment

    by:spunog
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    list of java output 2 27
    Annotation to do Dependency injection in spring 3 22
    powerN  challenge 3 20
    array11 challenge 16 25
    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now