Author Topic: Linux and Windows launcher-icons  (Read 970 times)

logFarm

  • Jr. Member
  • **
  • Posts: 81
  • Karma: +0/-0
    • View Profile
Linux and Windows launcher-icons
« 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 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
Linux

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:
  • platformHopper.desktop
  • wobbegong 2D.desktop
  • bubbles.desktop
  • cubeCracker.desktop
  • wobbegong3D.desktop
  • wobbegongXmp.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]
Encoding=UTF-8
Name=Platform Hopper
Comment=Wobbegong Platform Hopper
Exec=/home/userName/myGames/wobbegongPlatformHopper/launch.sh
Icon=/home/userName/myGames/wobbegongPlatformHopper/icon64.png
Type=Application

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.

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

Comment=
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.

Exec=
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.

icon=
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:
/home/userName/myGames/wobbegongPlatformHopper/

Quote
gameDir            (a directory) 
windows_icon.ico
icon128.png 
icon32.png
icon16.png 
icon64.png         (the icon I want to show on the desktop)
launch.sh            (launches wobbegongPlatformHopper.jar)
lib                (a directory)
README.TXT 
WobbegongPlatformHopper.jar

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:

1.
  • right click on your .desktop file
  • from the properties dialog select the Permissions tab
  • check the 'Allow execting file as program' check box



2.

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


Windows

In windows all you have to do is:
  • open notepad.exe

  • type the single line:

    Quote
    java -jar WobbegongPlatformHopper.jar

  • save the file as: launch.bat

    for example, c:\wobbegongPlatformHopper is the game directory, where WobbegongPlatformHopper.jar resides

    so save the file to:
    c:\wobbegongPlatformHopper\launch.bat

  • from the file manager, locate launch.bat and right click

  • select: create shortcut

    a separate file will be create called: launch.bat - Shortcut

  • drag or copy 'launch.bat - Shortcut' to your Windows desktop


Give the shorcut an icon
  • from your Desktop,  right click on: launch.bat - Shotcut

  • select: properties

  • from the Properties window, click the button: Change icon
    you are going to choose a particular .ico file

  • click Browse and navigate to c:\wobbegongPlatformHopper\
    and select: windows_icon.ico

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