Click here to Skip to main content
15,887,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Reading Registry Value</title>
        <script type="text/javascript">

            function readJREValue()
            {
            document.write("<b>Java Runtime Environment properties of your computer : </b>")
            document.write("<br>")
                var WshShell = new ActiveXObject("WScript.Shell");
                var value = WshShell.RegRead("HKLM\\Software\\JavaSoft\\Java Runtime Environment\\BrowserJavaVersion");
                document.write("Your JRE Browser Version Is: " + value);
                        document.write("<br>");
            };
        </script>
    </head>
    <body onload="javascript: readJREValue()">
    </body>
</html>



This code is working fine when i am running this from my desktop, But when i am trying to run from my localhost nothing happens...
Posted
Updated 12-Nov-13 8:40am
v2

It is a security issue.
In real word environment (not IDE debugging) your code runs inside the browser on the client machine AND TRY TO READS THE REGISTRY OF THE CLIENT!!!. However, browser security prevents from you to do so.

In any case I believe you missing here some point. Web applications by it's nature are parted to server-client... Means part of your code runs on the server and an other part on the client.
The part you presented here belongs to the client.

As I understand you want to check the installed Java version of the client. For that Oracle gives you JavaScript to do so...

Start here
http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit[^]

A sample to display installed versions

HTML
<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <script src="http://java.com/js/deployJava.js"></script>
    <title>JRE Versions</title>
</head>
<body>
    <div id="idJREs">

    </div>

    <script type="text/javascript">
        function getJREs() {
            document.getElementById('idJREs').innerText = deployJava.getJREs();
        }

        window.onload = getJREs;
    </script>
</body>

</html>
 
Share this answer
 
v2
Comments
Rayan Khan 11-Nov-13 7:45am    
Thanks For your reply..

can you give sample example to read the values in based of Oracle tool kit...
Kornfeld Eliyahu Peter 11-Nov-13 9:04am    
See updated solution
Prasad Khandekar 11-Nov-13 7:49am    
My 5+
Hello Ahmad,

For Security Reasons browsers won't allow JavaScript to access the local resources such as Disk, Files, Registry. Allowing such things via web browser would have pretty serious security consequences.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900