Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

java-3d

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!

like image 521
javydreamercsw Avatar asked Sep 29 '26 08:09

javydreamercsw


2 Answers

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.

like image 164
Ceilingfish Avatar answered Oct 01 '26 22:10

Ceilingfish


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");
}
like image 26
Wilson Waters Avatar answered Oct 01 '26 22:10

Wilson Waters