Team LiB
Previous Section Next Section

Hack 62. Get Browser Plug-ins Working

Liven up the Web with a plug-in or two.

The Web has long moved beyond its humble beginnings as a text-based medium. Now it is filled with dynamic content that includes animations, interactivity, video, sound, and other types of media. Special software, known as plug-ins, is usually required to use this new content. Getting plug-ins to work in Firefox can be a little difficult, so this hack explores how to get the two most common plug-ins working: Macromedia Flash and Java.

8.9.1. Use the Macromedia Flash Plug-in

The Macromedia Flash plug-in enables you to view animations on dynamic web sites. A few years back, installing Flash was a difficult and error-prone process, but luckily, the process has improved. First, download the Linux Flash plug-in from http://www.macromedia.com, and unzip it into a directory. Once it is extracted, you will see a number of files, including a file called flashplayer-installer. This file automates the process of installing Flash.

Before you can run the installer, you must change its permissions so that it is executable:

foo@bar:~$ chmod a+x flashplayer-installer

To run the installer and have it install the plug-in for you, type the following command:

foo@bar:~$ ./flashplayer-installer

Once you have run through this installation routine, load up Firefox and type the following into the address bar:

about:plugins

This page tells you the plug-ins Firefox has installed. Once you've installed the Flash plug-in, you should see two entries that look like this:

MIME Type

Description

Suffixes

Enabled

application/x-shockwave-flash

Shockwave Flash

swf

Yes

application/futuresplash

FutureSplash Player

spl

Yes


These two lines indicate that the player is correctly installed. Now you can test the player by visiting a Flash-based web site, such as the "fantastic" http://www.badgerbadgerbadger.com.

8.9.2. Use Java in Firefox

Java is a popular cross-platform programming environment in which you can theoretically write a single program, and have it run on a number of different operating systems and web browsers. Although the Java language was developed by Sun Microsystems, it has been licensed openly enough to allow a number of Java software interpreters to be developed by various companies and organizations.

To run Java programs, you need a Java Runtime Environment (JRE). This software lets you run Java programs either in a web browser or as a normal application. By far one of the most popular JREs available is from Sun at http://java.sun.com/j2se/. Other Java environments are available that work well with Firefox and normal Java desktop environments, but this hack covers just the official Sun incarnation.

One issue to bear in mind in terms of getting the right JRE is finding one that is compatible with Firefox. The first place you should check for this information is http://plugindoc.mozdev.org/. Traditionally, in terms of using Java within Firefox, the main source of problems is that the browser should be compiled with the same major version of the GNU C Compiler as the versions of the JRE you will be using. At the time of this writing, Firefox requires version 1.4.2 or later of the Sun JRE, as this version and most distributed versions of Firefox were compiled with version 3 of the GNU C Compiler. You can check which version your Firefox was compiled with by typing this into the address bar:

about:buildconfig

It is likely that your version of the browser was compiled with GCC 3.x and should be compatible with the Sun JRE 1.4.2 or above.

When you have downloaded and installed the Sun JRE, you will have a directory with all the files that are part of the JRE distribution. Inside this is a plugins directory. To enable Java support in Firefox, you need to create a symbolic link inside your Mozilla plug-ins directory. The actual file in the JRE that you are linking to is libjavaplugin_oji.so. You can create this link by going to your Mozilla plug-ins directory in your home directory (this should be .mozilla/plugins or .firefox/plugins), and type in the following command:

foo@bar:~$ ln -s /sources/jre/plugin/i386/ns610-gcc32/libjavaplugin_oji.so

This command assumes your JRE is in /sources/jre; you will need to adjust it for the actual directory on your machine. One point to note is that inside the /sources/jre/plugin/i386 directory are a number of subdirectories which correspond to different versions of Netscape. The ns610-gcc32 directory contains the correct plug-in for recent versions of Mozilla-based browsers (such as Firefox). If you want to make Java support available to every user on the system, you will need to make the symlink available in the system Mozilla plugins directory (such as /usr/lib/mozilla-firefox/plugins) as opposed to a particular user's plug-ins directory.

You can check that your installation works by typing this into the address bar:

about:plugins

You should see a number of lines showing that Java support is working. Then you can test the installation by accessing a web site that uses Java, such as http://java.sun.com/.

    Team LiB
    Previous Section Next Section