Mac OS X: java.lang.ClassNotFoundException: com.sun.java.browser.plugin2.DOM

Thilo picture Thilo · Jan 5, 2011 · Viewed 7.9k times · Source

I am trying to use the new LiveConnect features introduced in Java 6 Update 10.

Code looks like this (copied from the applet tutorial):

 Class<?> c = Class.forName("com.sun.java.browser.plugin2.DOM");
 Method m = c.getMethod("getDocument", java.applet.Applet.class);
 Document document = (Document) m.invoke(null, this);

But all I am getting is a ClassNotFoundException for the entry-point class.

This on the Mac, 10.6, with both Firefox and Safari.

Java Plug-in 1.6.0_22
Using JRE version 1.6.0_22-b04-307-10M3261 Java HotSpot(TM) 64-Bit Server VM

Is this not implemented on the Mac? Or do I need to configure something?

All I need to do is get and set the value of form elements on the page, so I would be fine with an older (pre-6u10) API if that works better.

Answer

Thilo picture Thilo · Jan 5, 2011

Found the answer in this thread:

Java 6 on the Mac does include Plugin2, but it is not the default. You can enable it in the Java Preferences by checking "Run applets in their own process".

I'll use the older API for better compatibility.