logFarm.net Public Forum

General Category => General Discussion => Topic started by: logFarm on Saturday 2015-September-26 04:00:45 PM

Title: Linux and Windows launcher-icons
Post by: logFarm on Saturday 2015-September-26 04:00:45 PM
I have a few Java games and here's how I created launcher-icons for Linux and Windows Vista.

I'll be using: http://www.logfarm.net/wobbegongPlatformHopper.html (http://www.logfarm.net/wobbegongPlatformHopper.html) for this example.

You can get the game by visiting that web site or use wget:

Code: [Select]
wget http://www.logfarm.net/wobbegongPlatformHopper.zip

Here's a screen shot of the launchers on my Ubuntu desktop:


These launchers are just text files with a .desktop extension and placed on my Ubuntu desktop:

.desktop files are well described here:

A Google search for: .desktop files description

will list thousands more.

platformHopper.desktop looks like this:

Code: [Select]
[Desktop Entry]
Name=Platform Hopper
Comment=Wobbegong Platform Hopper

I'll assume you are going to base your .desktop files on platformHopper.desktop and so I'll just describe the parts you will need to change.

This text will be the text displayed under the icon on your Linux Desktop.

This text does little more than remind anyone who looks at the .desktop text what this launcher does but should be considered tool tip text.

This text is the command line that will actually launch the program. In my case, I have the full path to a file called: launch.sh

launch.sh is a very simple executable script:

Code: [Select]
cd ~/myGames/wobbegongPlatformHopper
java -jar WobbegongPlatformHopper.jar

I'll describe launch.sh and why I've created a separate script file rather than just 'java -jar etc ...' (which I could've done) in a moment.

The full path to a PNG image file, the icon that will be displayed on the Desktop.

launch.sh, what's that for ?
Shown above, first moves the command interpreter into the wobbegongPlatformHopper directory and from there runs a java command line.

Here's a list of files in:

gameDir            (a directory) 
icon64.png         (the icon I want to show on the desktop)
launch.sh            (launches wobbegongPlatformHopper.jar)
lib                (a directory)

WobbegongPlatformHopper.jar requires the files located in the wobbegongPlatformHopper/lib directory to run so rather than create a separate launch.sh file I could use the command line:

Code: [Select]
java -jar /pathTo/WobbegongPlatformHopper.jar -classpath /pathTo/lib

however WobbegongPlatformHopper.jar has a hardcoded reference to the directory: gameDir
and assumes it is in the same directory as: WobbegongPlatformHopper.jar

This is why I created a separate launch.sh file that is launched by platformHopper.desktop

Both launch.sh and the .desktop files have to be set as executable

This can be done in a few ways:




from a command line type:

Code: [Select]
chmod 755 /pathTo/your.desktop
chmod 755 /pathTo/launch.sh

The .desktop file should be placed on your Linux Desktop.

Trouble shooting

if your .desktop file does not show an icon:

- the .desktop file needs to be set executable

- Exec= text needs the full path to the launch.sh or the command line is not valid

  run the command line from a command prompt to make sure it works

- the Icon= text is not pointing at a .png file

  run the text from a command prompt like this:
Code: [Select]
display pathTo/yourIcon.png
  your icon will be displayed if the path is correct


In windows all you have to do is:

Give the shorcut an icon

I hope these steps get you on the road to creating launchable icons for your Linux and Windows desktops.

Sorry for the lack of Macintosh instructions but I don't have access to a Macintosh desktop.

Best regards