Unfortunately, that doesn’t work. That code fragment is exactly what I was trying to do. But it throws this exception:
java.lang.NoClassDefFoundError: javax/media/j3d/GraphicsConfigTemplate3D
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
at java.lang.Class.getConstructor0(Class.java:1762)
at java.lang.Class.newInstance0(Class.java:276)
at java.lang.Class.newInstance(Class.java:259)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1775)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)
at sun.applet.AppletPanel.run(AppletPanel.java:292)
at java.lang.Thread.run(Thread.java:536)
As you can see from the stacktrace, there’s no point in there when I’m actually in my applet. This is all the applet loading framework. It’s trying to ensure all the classes are there before it starts the applet.
Another way I tried was to do this:
try {
Class.forName("javax.media.j3d.VirtualUniverse");
}
catch (ClassNotFoundException e) {
myApplet.textArea.append("Java3D does not appear to be installed!" + newline);
}
This won’t work because of the sandbox. I get an AccessControlException.
Finally, there are only a few system properties that can be read by the applet. Again, this is due to security. Sun talks about this at http://java.sun.com/docs/books/tutorial/applet/practical/properties.html where there’s a niftly applet that show’s what you can get.
I may have to resort to several applets that load each extension I want to test for and say “Did that work?” on each one of them. It’s very cheesy and not as nice as a single applet that would give a single report.