开发者

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 a开发者_如何学Cbout missing requirements. Thanks in advance!


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.


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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜