javydreamercsw
javydreamercsw

Reputation: 5129

How can I check if Java 3D is installed from my java application?

How can I check if Java 3D is instaled on the client? I can use that to display a message about missing requirements. Thanks in advance!

Upvotes: 3

Views: 1557

Answers (2)

Wilson Waters
Wilson Waters

Reputation: 643

I had a similar problem. In my case the J3D jar file was available but not the platform binaries.

try
{
   GraphicsConfigTemplate3D gconfigTemplate = new GraphicsConfigTemplate3D();
   GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(gconfigTemplate);
}
catch (Error e) // You shouldn't normally catch java.lang.Error... this is an exception
{
   System.out.println("Java3D binaries not installed");
}

Upvotes: 2

Ceilingfish
Ceilingfish

Reputation: 5455

You could try loading a class from the Java 3D API and put your logic in the catch statement. ie

try {
    Class.forName("javax.media.j3d.J3DBuffer")
}
catch(final ClassNotFoundException e) {
//Your logic here
}

I know, I know, exceptions should not be expected.

Upvotes: 3

Related Questions