Bug 17607 - 'java' object not exposed to js
Summary: 'java' object not exposed to js
Status: RESOLVED DUPLICATE of bug 15109
Alias: None
Product: WebKit
Classification: Unclassified
Component: Java (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL: javascript:alert(java.lang.System.get...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-29 08:34 PST by Michael A. Puls II
Modified: 2010-02-23 16:03 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael A. Puls II 2008-02-29 08:34:08 PST
(Safari 3.1.525.9)

In JS with Java installed, you should be able to get the Java version by doing:
alert(java.lang.System.getProperty("java.version"));

This fails because 'java' is not exposed to js. Works fine in Opera and FF.
Comment 1 Robert Blaut 2008-03-02 02:56:41 PST
It's by design. You cannot call Java directly from javascript. First you should create an applet on the page. After that you can use LiveConnect to call methods from the applet using JavaScript. This *proper* method works fine in Webkit.

Check this page to read how to do it: http://www.whatscookin.com/staff/mattd/articles/jre-detection.html
Comment 2 Michael A. Puls II 2008-03-02 05:31:10 PST
Thanks.

I was referring to < http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Packages > and < http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:java >. For example:

<script>
(function() {
    var theOwner = new java.awt.Frame();
    var theWindow = new java.awt.Dialog(theOwner);
    theWindow.setSize(350, 200);
    theWindow.setTitle("Hello from Opera and Firefox");
    theWindow.setVisible(true);
    theWindow.show(true);
    setTimeout(function() {
        theWindow.dispose();
    }, 5000);
})();
</script>

(In reply to comment #1)
> It's by design.

O.K., this is invalid then.
Comment 3 Alexey Proskuryakov 2010-02-23 16:03:41 PST

*** This bug has been marked as a duplicate of bug 15109 ***