logo

Home page
Articles for Windows, Linux, OS X
Mac tips and articles
Mac tips
Windows 8 tips and articles
Windows 7 tips and articles
Vista Tips
XP Tips
Linux tips and articles
Read the blog
Online store
Windows, Linux, OS X programs
Links
About

Linux tips and tweaks

Create shortcuts and menus to run Java applications

One of the problems with writing software is that each operating system is different and it causes many a headache for the programmer. It means that software that has been designed to run in Windows won't run in Linux or on the Mac, Linux applications won't run on Windows and so on. There are some great applications for other operating systems - if only they were written for the one we actually use! Java was designed to be a write-once-run-anywhere system and the idea is that a programmer only has to write an application once and then it can be run on any operating system that supports Java, and most do. It's not quite the perfect cross-platform tool that it was intended to be, but Java applications usually work on Linux, Windows and OS X quite well. Here's how to create desktop shortcuts and menu items to run Java applications in Linux.

First you need to make sure that you have Java installed on your computer. Go to www.java.com and download it and install it yourself, or, and this is a better option, install it using your distro's software manager. For example, in Ubuntu Linux you should go to the System menu, then Administration and run Synaptic Package Manager. Use the search facility to find 'java' and then select the Java runtime environment for installation. In Ubuntu you just right click sun-java6.bin and mark for installation. Several other Java components are automatically selected for you and everything you need is installed.

Now that you have Java installed, you can run any Java application. There are are lots of them on the web and finding them isn't difficult. For example, there's a good HTML web page editor called Arachnophilia or there's Makagiga, which is a multi-function utility that includes to-do, RSS reader, notepad and widgets. We'll use Makagiga in the following example, but the same method works for all Java applications.

Download the portable cross-platform version, because that's the Java version. It's a zip file, but if you double click it after downloading it, it opens in Archive Manager and you can drag the contents out the magagiga folder - and drop it wherever you want it. You can place it in the Home folder if you want.

If you open the home folder and then the makagiga folder, you'll see that it contains lots of files. The number varies from application to application and there may be one file or there might be many. Look for makagiga.jar because that's the Java application. Right click it and select Open with Java 6 Runtime. Makagiga runs just like a normal application.

Now you know how to run Java apps through the graphical user interface, let's try it from the command line. Close Makagiga if it is still running and open a Terminal window. You'll need to change to the makagiga folder wherever you placed it when you unzipped it. Probably cd makagiga will suffice if you've put it in your home folder. Now type java -jar makagiga.jar and you'll see the Makagiga program open just as before.

That command is what you need when you create a desktop shortcut or menu item. Right click the desktop and select Create launcher. Leave the type set to Application and then enter a name for the shortcut, such as Makagiga. Click the Browse button next to Command and select the makagiga.jar file. The path to the file is entered into the Command box and you need to click in it and edit it so it says java -jar /home/roland/makagiga/makagiga.jar or something similar. Basically, you just put java -jar in front of the path. Click OK and the shortcut is created.

Finally, let's add it to one of the menus. In Ubuntu go to System, Preferences, Main Menu. Choose the menu you want to add it to in the left pane and then click New Item on the right. It's exactly the same as creating the shortcut on the desktop. In fact, you can drag the shortcut to the Main menu window and drop it on the menu item list to add it.

That's basically how you download, install and run Java applications. Most others are the same. However, it's always worth looking at the documentation just in case. With Makagiga, there's actually a script that you can run called run-portable.sh. It does a few extra things before running the Java application, like creating a data folder. You can modify the shortcut or menu item to run it instead of the Java file.

Java application

Grab some Java apps

If you want to try some Java applications, go to http://java-apps.org, where you'll find some excellent ones. It's not the only source of apps, but it's a good place to start.



Go to Linux tips index...

copyright