ellandrd
asked on
find JRE version
how can i find and display the JRE version installed on machine?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
of course, the javascript will not work until the applet has fully loaded...
ASKER
see i dont think this will work for me.
ive got webpage X that uses an applet and redirects to webpage Y.
but what ive found is that webpage X wont work (applet dont get loaded webpage X hangs) unless the user has an JRE installed, hence why i want to check for an JRE first but trying to load & start applet.
ive got webpage X that uses an applet and redirects to webpage Y.
but what ive found is that webpage X wont work (applet dont get loaded webpage X hangs) unless the user has an JRE installed, hence why i want to check for an JRE first but trying to load & start applet.
ASKER
>>hence why i want to check for an JRE first but trying to load & start applet.
should read
hence why i want to check for an JRE first before trying to load & start applet.
should read
hence why i want to check for an JRE first before trying to load & start applet.
Here's an excerpt from one of the comments in the sun developer forum: Note the IE stipulation
Try following java script, it works on new browsers (NS 4+, IE5+). For IE you have to enable 'ActiveX objects creation' in security options.
var agt=navigator.userAgent.to
var is_major = parseInt(navigator.appVers
var is_nav = ((agt.indexOf('mozilla')!=
&& (agt.indexOf('compatible')
&& (agt.indexOf('webtv')==-1)
var is_nav4up = (is_nav && (is_major >= 4));
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0") !=-1));
var is_ie5up = (is_ie && (is_major == 4)
&& ( (agt.indexOf("msie 5.0")!=-1)
|| (agt.indexOf("msie 5.5")!=-1)
|| (agt.indexOf("msie 6.0")!=-1) ) );
var pluginDetected = false;
var activeXDisabled = false;
// we can check for plugin existence only when browser is 'is_ie5up' or 'is_nav4up'
if(is_nav4up) {
// Refresh 'navigator.plugins' to get newly installed plugins.
// Use 'navigator.plugins.refresh
// without refreshing open documents (browser windows)
if(navigator.plugins) {
navigator.plugins.refresh(
}
// check for Java plugin in installed plugins
if(navigator.mimeTypes) {
for (i=0; i < navigator.mimeTypes.length
if( (navigator.mimeTypes[ i].type != null)
&& (navigator.mimeTypes[ i].type.indexOf(
"application/x-java-applet
pluginDetected = true;
break;
}
}
}
} else if (is_ie5up) {
var javaVersion;
var shell;
try {
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.She
if (shell != null) {
// Read JRE version from Window Registry
try {
javaVersion = shell.regRead("HKEY_LOCAL_
} catch(e) {
// handle exceptions raised by 'shell.regRead(...)' here
// so that the outer try-catch block would receive only
// exceptions raised by 'shell = new ActiveXObject(...)'
}
}
} catch(e) {
// Creating ActiveX controls thru script is disabled
// in InternetExplorer security options
// To enable it:
// a. Go to the 'Tools --> Internet Options' menu
// b. Select the 'Security' tab
// c. Select zone (Internet/Intranet)
// d. Click the 'Custom Level..' button which will display the
// 'Security Settings' window.
// e. Enable the option 'Initialize and script ActiveX controls
// not marked as safe'
activeXDisabled = true;
}
// Check whether we got required (1.3+) Java Plugin
if ( (javaVersion != null) && (javaVersion.indexOf("1.3"
pluginDetected = true;
}
}
if (pluginDetected) {
// show applet page
} else if (confirm("Java Plugin 1.3+ not found, Do you want to download it?")) {
// show install page
} else {
// show error page
}
ASKER
Ok half working...
i use 1.5.0_07 and im forcing all users to be the same...
my reg key is:
HKEY_LOCAL_MACHINE\\Softwa re\\JavaSo ft\\Java Runtime Environment\\1.5.0_07
i have tried this but dont work:
javaVersion = (shell.regRead("HKEY_LOCAL _MACHINE\\ Software\\ JavaSoft\\ Java Runtime Environment\\1.5.0_07")) ? "1.5.0_07" : "1.3" ;
i use 1.5.0_07 and im forcing all users to be the same...
my reg key is:
HKEY_LOCAL_MACHINE\\Softwa
i have tried this but dont work:
javaVersion = (shell.regRead("HKEY_LOCAL
why 1.5.0_07?
Surely just "1.5.0" or better would do?
Forcing people to use a particular update of a particular version seems a little restrictive (and harsh)
Surely just "1.5.0" or better would do?
Forcing people to use a particular update of a particular version seems a little restrictive (and harsh)
Why not
javaVersion = shell.regRead("HKEY_LOCAL_ MACHINE\\S oftware\\J avaSoft\\J ava Runtime Environment\\CurrentVersio n");
if (javaVersion !='1.5.0_07') { alert('Nope'); javaVersion='1.3'; }
else ...
javaVersion = shell.regRead("HKEY_LOCAL_
if (javaVersion !='1.5.0_07') { alert('Nope'); javaVersion='1.3'; }
else ...
ASKER
because i dont have a folder called "CurrentVersion" in my registry...
after HKEY_LOCAL_MACHINE\\Softwa re\\JavaSo ft\\Java Runtime Environment\\
i have a folder "1.5" & another folder "1.5.0_07"
after HKEY_LOCAL_MACHINE\\Softwa
i have a folder "1.5" & another folder "1.5.0_07"
ASKER
sorry tim didnt see your post.
ya 1.5 would do... i wasnt thinking while i typed a reply....
ya 1.5 would do... i wasnt thinking while i typed a reply....
ASKER
ok the script isnt even getting to that point.
ive insertted some debugging statements and the script stops right before:
document.writeln("here");
// we can check for plugin existence only when browser is 'is_ie5up' or 'is_nav4up'
if(is_nav4up)
{
...
on my page, the only statement i see is "here"...
im actually testing this on IE7, but my users use IE5+
ive insertted some debugging statements and the script stops right before:
document.writeln("here");
// we can check for plugin existence only when browser is 'is_ie5up' or 'is_nav4up'
if(is_nav4up)
{
...
on my page, the only statement i see is "here"...
im actually testing this on IE7, but my users use IE5+
ASKER
ok, i tested it in IE5+ and it now fails here:
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.She ll");
any idea's?
// Create WSH(WindowsScriptHost) shell, available on Windows only
shell = new ActiveXObject("WScript.She
any idea's?
ASKER
OK, i cannot get script to work as the security build into IE7 wont allow webpage to be run with initialize and script ActiveX controls enabled, but IE5+ will so i now have want i want working...
just let me give it a few more tests before i accept...
ellandrd
just let me give it a few more tests before i accept...
ellandrd
How do you get
alert("JRE Version: " + document.myApplet.getJavaV ersion());
to work????
I get Object does not support....
<HTML>
<Head>
<Title> A Simple Program </Title>
<script>
function showStuff() {
showIt=true
var x = document.getElementById('a pp');
txt = "";
try {
txt += 'version:'+x.getJavaVersio n()
for (i in x) {
txt +='<hr>'+i
if (i!='outerHTML') txt +=':<br>'+((x[i])?x[i]:'no t set')
}
txt+='<hr>'
}
catch(e) { alert(e.message)}
document.getElementById('r esu').inne rHTML=txt;
}
</script>
<Body onLoad="showStuff()">
<Applet id="app" Code="HelloWorld.class" width="150" height="50"></Applet>
<div id="resu"></div>
</Body>
</HTML>
alert("JRE Version: " + document.myApplet.getJavaV
to work????
I get Object does not support....
<HTML>
<Head>
<Title> A Simple Program </Title>
<script>
function showStuff() {
showIt=true
var x = document.getElementById('a
txt = "";
try {
txt += 'version:'+x.getJavaVersio
for (i in x) {
txt +='<hr>'+i
if (i!='outerHTML') txt +=':<br>'+((x[i])?x[i]:'no
}
txt+='<hr>'
}
catch(e) { alert(e.message)}
document.getElementById('r
}
</script>
<Body onLoad="showStuff()">
<Applet id="app" Code="HelloWorld.class" width="150" height="50"></Applet>
<div id="resu"></div>
</Body>
</HTML>
You can't call it onload
You have to call it after the applet is loaded (via a link or timer or something)
I *think* that's the problem...
You have to call it after the applet is loaded (via a link or timer or something)
I *think* that's the problem...
Nope
<HTML>
<Head>
<Title> A Simple Program </Title>
<script>
function showStuff() {
showIt=true
var x = document.getElementById('a pp');
txt = "";
try {
txt += 'version:'+x.getJavaVersio n()
for (i in x) {
txt +='<hr>'+i
if (i!='outerHTML') txt +=':<br>'+((x[i])?x[i]:'no t set')
}
txt+='<hr>'
}
catch(e) { alert(e.message)}
document.getElementById('r esu').inne rHTML=txt;
}
</script>
<body onLoad="setTimeout('showSt uff()',200 0)">
<Applet id="app" Code="HelloWorld.class" width="150" height="50"></Applet>
<div id="resu"></div>
</Body>
</HTML>
<HTML>
<Head>
<Title> A Simple Program </Title>
<script>
function showStuff() {
showIt=true
var x = document.getElementById('a
txt = "";
try {
txt += 'version:'+x.getJavaVersio
for (i in x) {
txt +='<hr>'+i
if (i!='outerHTML') txt +=':<br>'+((x[i])?x[i]:'no
}
txt+='<hr>'
}
catch(e) { alert(e.message)}
document.getElementById('r
}
</script>
<body onLoad="setTimeout('showSt
<Applet id="app" Code="HelloWorld.class" width="150" height="50"></Applet>
<div id="resu"></div>
</Body>
</HTML>
<Applet id="app" Code="HelloWorld.class" width="150" height="50" MAYSCRIPT></Applet>
?
?