I’ve had some experience with Java and Javascript and searching this forum has helped me tremendously, but haven’t been able to find this exact problem explicitly. In a nutshell: I want to call a java class straight from Javascript i.e. use a Java class in Javascript without OBJECT or APPLET.
Here’s what what I’m experimenting with:
function screenSize() {
alert("Screen Dimension\n" + " width:"
+ java.awt.Toolkit.getDefaultToolkit().getScreenSize().width
+ " height:" + java.awt.Toolkit.getDefaultToolkit().getScreenSize().height);
}
which is an example given on http://www.rgagnon.com/javadetails/java-0170.html. This is hooked to a button on a page. When clicking the button I (in essence) get:
A Runtime Error has occured at line 35: ‘java’ is undefined.
I’m assuming that my path is incorrect or missing and there’s a PATH or CLASSPATH or something I’ve overlooked.
I’d eventually like to move the javascript into a bookmarklet so that the user will be able to click a favorite on the appropriate page and have magic happen because of my own java classes manipulating the data from the screen. For various reasons political and technical, I’m stuck using IE6-7 and have to work with scraping the web page in the browser and processing it on the client — no sever side action for me! I can assume that a JRE 6 will be available.
Is it a path issue? Is what I want even possible and if so, how? And how will packages work with all this?
Any advice or examples will be muchly appreciated.
The tip shown at Real’s HowTo used to work, but doesn’t anymore. Insert an applet and define public methods to interact with.