Home | Gaming | Programming | Play Online | Contact | Keyword Query
Games++ Games & Game Programming

GAMES++
Games++ Home
Games++ Gaming
Games++ Programming
Beta Testing Games
Free Online Games
Hints & Cheats

BROWSER UTILITIES
E-mail This Page
Add to Favorites

SITE SEARCH

Web Games++

AFFILIATES
Cheat Codes
Trickster Wiki
Game Ratings
Gameboy Cheats
PlayStation Cheats
BlackBerry Games
Photoshop Tutorials
Illustrator Tutorials
ImageReady Tutorials

ADVERTISEMENT

ADVERTISEMENT

How To Detect If A Package Is Available

Java How To: Source Code

public class JustTesting 
{
	public static void  main(String args[]) 
	{
		System.out.println("Swing " 
			+ (isAvailable("javax.swing.JComponent")   ? "present" : "absent"));
		System.out.println("JAI " 
			+ (isAvailable("javax.media.jai.ImageJAI") ? "present" : "absent"));
		System.out.println("SAX " 
			+ (isAvailable("org.xml.sax.XMLReader")    ? "present" : "absent"));
		System.out.println("Java3d " 
			+ (isJava3dAvailable()                     ? "present" : "absent"));
	}

	public static boolean isAvailable(String className) 
	{
		boolean isFound = false;

		try 
		{
			Class.forName(className);
			isFound = true;
		}
		catch (ClassNotFoundException e) 
		{
			isFound = false;
		}

		return isFound;
	}

	public static boolean isJava3dAvailable() 
	{
		return isAvailable("javax.media.j3d.View");
	}
}

Copyright © 1998-2007, Games++ All rights reserved. | Privacy Policy