I read that you could call JavaScript code from a Java Applet by calling
JApplet.getAppletContext().showDocument( "javascript:alert('Hello World');" );
However, when I do this i get the following error:
java.net.MalformedURLException: unknown protocol: javascript
How do I work around this?
Works !!
Maybe the browser does not have javascript enabled.. just a guess
I get the same exception as you do because of that the URL class does not accept javascript: as a valid protocol.
There is a workaround though; supply an URLStreamHandler to the URL constructor.
Example: