Hack48.Run Java Applets Without Crashes or Problems


Hack 48. Run Java Applets Without Crashes or Problems

To get the most out of surfing the Web, you need the most recent version of Java. That can be harder to get than you think, but this hack will show you how.

Running a Java applet when you visit a web site should be a no-brainer; click a link and the application should run. Unfortunately, XP users have found out that isn't always the case. You might visit Java sites only to find that you can't play games, log into interactive stock and weather sites, or do any of the other things Java can be used for.

Unfortunately, there's no single fix for all Java woes. There are many potential causes, ranging from display errors, to running an old version of Java, and more. Here, though, are the primary ways you can fix Java on your machine.

4.18.1. Make Sure You Have a Java Virtual Machine (JVM) Installed

To run Java applets, you need a Java Virtual Machine (JVM) installed on your system. Microsoft and Sun have, in the past, had competing JVMs. Applets written for one JVM might or might not work with the other JVM.

To make things more confusing, Microsoft and Sun have been locked in a bitter legal battle about Java, which rivals the Jarndyce and Jarndyce court case at the center of Dickens' novel Bleak House. Fully explaining the Microsoft/Sun fight would take about as many pages as Dickens' 1,000-plus-page novel did. The upshot is this, however: because of a court ruling, Microsoft stopped distributing and supporting its JVM (which it calls Microsoft VM) in January 2004. And the Microsoft VM might or might not be enabled in your version of XP.

So, if you're having problems with Java, the first thing to do is to see whether you have a JVM installed and whether you're using the Sun version, the Microsoft version, or both versions. To see whether Microsoft VM is enabled, from Internet Explorer choose Tools Internet Options Security. Highlight the Internet Zone, choose Custom Level, and then scroll down until you come to the Microsoft VM section, shown in Figure 4-59.

Figure 4-59. Checking to see whether you're using the Microsoft VM


If the Disable Java button is chosen, it means the Microsoft VM is disabled on your system.

To check whether you have the Sun JVM and whether it's enabled, from Internet Explorer choose Tools Internet Options Advanced and scroll down. If you see a Java (Sun) entry with a checkbox next to it, as pictured in Figure 4-60, the Sun JVM is installed.

Figure 4-60. Checking to see whether the Sun JVM is installed


If you don't have the Microsoft VM or the Sun JVM installed, the solution is simple: install and enable one of them. Because Microsoft stopped supporting its VM after January 2004, your best bet is to install the Sun JVM from http://www.java.com/en/download/windows_automatic.jsp.

If the Microsoft VM or the Sun JVM shows up (as in Figure 4-59 or Figure 4-60, respectively), but it's not enabled, you'll need to enable it. To enable the Microsoft VM, in the screen pictured in Figure 4-59 choose High Safety. That will enable the VM but will take security precautions against rogue Java applets. To enable the Sun JVM, select the checkbox under Java (Sun), as shown in Figure 4-60.

4.18.2. Uninstall Older JVM Versions

Your problem might be that you have an older JVM or Microsoft VM installed, and you need to update it. Go to http://java.sun.com and check the version number against the version number displayed in Figure 4-60. If your version number is older, you should install a newer JVM. Additionally, if you're using the Microsoft VM, you might instead want to install the Sun JVM in its place, since Microsoft discontinued support for its VM.

People have reported problems when installing a newer JVM over an older one, so I suggest first uninstalling the old JVM or Microsoft VM and then installing the new one from http://www.java.com/en/download/windows_automatic.jsp. Unfortunately, uninstalling the Sun JVM or Microsoft VM is not a simple process and requires Registry editing as well as manually deleting files. Here's how to do each.

4.18.2.1 Uninstalling an old Sun JVM

There's good news and bad news about uninstalling an old Sun JVM. The good news is that it might go off without a hitch and take only a single step. The bad news is that you might not be so lucky, and then it'll be time to head to the Registry.

To uninstall an old Sun JVM, choose Control Panel Add/Remove Programs. Select the Java Runtime Environment entry, click Change/Remove, and follow the uninstallation wizard. The JVM will beor should beuninstalled.

Sometimes, however, even after you do that, the Java Runtime Environment entry remains in the Add or Remove Programs screen. Theoretically, this should not cause a problembecause the underlying JVM has been uninstalledbut it's not clear whether in practice it will cause problems. So, you'll be best off to remove the entry in the Add or Remove Programs screen. You'll do it by deleting Registry entries and a folder.

Run the Registry Editor [Hack #83] and go to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Uninstall. You'll find many keys enclosed in curly brackets, like this: {B7915B05-FC28-11D6-9D24-00010240CE95}. One of these keys is the Java uninstall Registry entry, and you need to delete it. You won't be able to know which entry to delete by the key name because the keys aren't descriptive and each is a string of long numbers enclosed in curly brackets. To find which to delete, you need to find the one that has a DisplayName with a String value that starts with Java, such as Java 2 SDK, SE v1.4.1_02. To find out which key to delete, search for the word Java by pressing Ctrl-F in the Registry, typing the word Java, and then doing a search for it. You'll be brought to the key that needs to be deleted. Before deleting the key, write down its entire name because you'll need it for the next step. Then you'll delete it.

Next, go to the uninstall folder for Java and delete that folder. Delete C:\Program Files\InstallShield Installation Information\{<Java 2 clsid key>}, where {<Java 2 clsid key>} is the value of the registry key you deleted. After you do that, when you restart Add or Remove Programs the Java entry will be gone.

4.18.2.2 Uninstalling the Microsoft VM

Uninstalling the Microsoft VM takes a bit of work as well. From the Run box, enter the command RunDll32 advpack.dll,LaunchINFSection java.inf,UnInstall. You'll get a warning box asking if you want to go through with the uninstallation process. Click Yes to continue, and reboot your PC when prompted.

After you reboot, delete these items:

  • The C:\Windows\java folder

  • The java.pnf file from the C:\Windows\inf folder

  • The jview.exe and wjview.exe files from the C:\Windows\system32 folder

  • The Registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM

  • The Registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\AdvancedOptions\JAVA_VM

That will completely remove the Microsoft VM. Now you can install the Sun JVM from http://www.java.com/en/download/windows_automatic.jsp.

4.18.3. Change Your Display Settings

Java applets won't run unless you have a minimum color setting of 256 colors. If you don't use that minimum setting, you'll crash when you visit a web page with a Java applet. To change your display settings, right-click the desktop, choose Properties Settings, and in the Color Quality drop-down box choose a display setting of at least 256 colors.

If you use at least 256 colors and you still experience problems, the cause might be a buggy video driver. To help find out if this is the cause of the problem, change your current display settings to a lower resolution and color depth than you're currently usingfor example, bring it from 1,024 768 to 800 600, and the colors from Highest (32bit) to 256 colors. If that doesn't solve the problem, you might have a display driver with bugs in it. Go to the manufacturer's web site and download a new driver.



    Windows XP Hacks
    Windows XP Hacks, Second Edition
    ISBN: 0596009186
    EAN: 2147483647
    Year: 2003
    Pages: 191

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net