Make a call to System.getProperties(). That will return a properties
object that contains information about your environment. The
'java.version' key will return a value with what you are looking for.
This also has other information that may be useful for your needs. For
further information check out:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()
> Make a call to System.getProperties(). That will return a properties
> object that contains information about your environment. The
> 'java.version' key will return a value with what you are looking for.
> This also has other information that may be useful for your needs. For
> further information check out:
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()
This doesn't seem to be possible when done via applets?
I say that because when I tried to run it via an applet, I got this
error message:
exception: java.security.AccessControlException: access denied
(java.util.PropertyPermission * read,write).
Andrew Thompson - 20 Nov 2006 21:56 GMT
> > Make a call to System.getProperties(). That will return a properties
> > object that contains information about your environment. The
[quoted text clipped - 3 lines]
> > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()
> This doesn't seem to be possible when done via applets?
Sure it is, if the applet is signed and trusted.
Finding all the properties that are defined could
be a security risk, so an untrusted applet will only
ever allow certain information to be obtained,
and will not give the 'full list' of properties defined.
> I say that because when I tried to run it via an applet, I got this
> error message:
>
> exception: java.security.AccessControlException: access denied
> (java.util.PropertyPermission * read,write).
Try calling for each property of interest separately,
in this case..
System.getProperty("java.version");
Note it might be handy to run the 'getProperties()'
from the command line to find out the typical property
names.
Andrew T.
Eric Sosman - 20 Nov 2006 22:01 GMT
yawnmoth wrote On 11/20/06 16:32,:
>>Make a call to System.getProperties(). That will return a properties
>>object that contains information about your environment. The
[quoted text clipped - 10 lines]
> exception: java.security.AccessControlException: access denied
> (java.util.PropertyPermission * read,write).
Try (and I say "try" because I haven't tried it myself)
String javaversion = System.getProperty("java.version");
The security manager may be willing to let you read a subset
of the properties but not all of them.

Signature
Eric.Sosman@sun.com
Andrew Thompson - 20 Nov 2006 23:39 GMT
...
> Try (and I say "try" because I haven't tried it myself)
>
> String javaversion = System.getProperty("java.version");
..or try it here..
<http://www.physci.org/pc/jtest-applet.jnlp>
That (sandboxed) applet indicates some of the properties
that are allowed and blocked, for an untrusted applet..
Andrew T.
Mickey Segal - 21 Nov 2006 03:21 GMT
> <http://www.physci.org/pc/jtest-applet.jnlp>
At www.segal.org/java/config/ we use the following code to get the maximal
information about the Java version:
if ((System.getProperty("java.vendor").startsWith("Microsoft")))
javaVersion = "java.version = " +
System.getProperty("java.version");
else javaVersion = "java.vm.version = " +
System.getProperty("java.vm.version");
The applet is unsigned and it works without security messages in any
environment that I've checked.
yawnmoth - 28 Nov 2006 18:57 GMT
> > <http://www.physci.org/pc/jtest-applet.jnlp>
>
[quoted text clipped - 9 lines]
> The applet is unsigned and it works without security messages in any
> environment that I've checked.
I'm using a technique similar to this, now, and am being told by
someone that it crashes their browser.
Here's my code:
import java.applet.*;
import java.awt.*;
public class ShowInfo extends Applet
{
String output = "", javaVendor, javaVersion;
public void start() {
try {
javaVendor = System.getProperty("java.vendor");
javaVersion = javaVendor.startsWith("Microsoft") ?
System.getProperty("java.version") :
System.getProperty("java.vm.version");
} catch (Exception e) {
//e.printStackTrace();
}
}
public void paint(Graphics g) {
g.drawString(javaVendor,10,25);
g.drawString(javaVersion,10,50);
}
}
I tried it, myself, on IE6 with MSJVM 1.1 and FF2 with Sun JVM 1.5 and
both worked. I don't know what browser their using nor do I know the
JVM vendor / version (that's what this script was supposed to find
out...)
Any ideas? Maybe I should be using something more like what Arne
Vajh?j posted?
Andrew Thompson - 28 Nov 2006 21:52 GMT
> I'm using a technique similar to this, now, and am being told by
> someone that it crashes their browser.
URL? (of the applet)
Browser (make and version) that crashed?
Java version (the browser was running) when crashed? ....oh. OK.
> Any ideas?
1) Ensure the code is compiled suitable for a Java 1.1 VM.
That involves both specifying a target version when comiling,
and most importantly, compiling against a 1.1 version rt.jar.
2) Provide the URL of the applet so I can check it in a 1.1 VM
(I have two available).
>..Maybe I should be using something more like what Arne
> Vajhøj posted?
I suspect Arne's suggestion uses much the same
techniques as used by myself and Mickey, though
note that Mickey's version has extra subtlety over either
mine or Arne's (it delves into details of the MSVM itself,
that are unavaiable to the other two).
Andrew T.
yawnmoth - 07 Dec 2006 20:17 GMT
> > I'm using a technique similar to this, now, and am being told by
> > someone that it crashes their browser.
>
> URL? (of the applet)
> Browser (make and version) that crashed?
> Java version (the browser was running) when crashed? ....oh. OK.
Sorry for the delay - the person who had their browser crash never
replied to my requests for more information.
Anyway, here's the URL:
http://www.geocities.com/terra1024/showInfo.html
The source of ShowInfo.class is here:
http://www.geocities.com/terra1024/ShowInfo.java
Andrew Thompson - 08 Dec 2006 00:53 GMT
> > > I'm using a technique similar to this, now, and am being told by
> > > someone that it crashes their browser.
> >
> > URL? (of the applet)
..
> http://www.geocities.com/terra1024/showInfo.html
I just tested it in IE using the Sun (1.5.something) plug-in
and then switched to the MSVM (1.1.4) to test it again.
On both occasions the applet came up in the web page
and showed the versions.
I suspect if your user flushes the cache (of any stray
classes from the old version), everything should be fine.
Andrew T.
Mickey Segal - 08 Dec 2006 01:48 GMT
> I just tested it in IE using the Sun (1.5.something) plug-in
> and then switched to the MSVM (1.1.4) to test it again.
[quoted text clipped - 3 lines]
> I suspect if your user flushes the cache (of any stray
> classes from the old version), everything should be fine.
I remember that there was some problem on Macintosh OS 9 at some point, but
if I remember correctly my code was even safe there.
Andrew Thompson - 08 Dec 2006 02:19 GMT
...
> Anyway, here's the URL:
>
> http://www.geocities.com/terra1024/showInfo.html
I forgot to check at the time, but ..because that HTML
is being served by GeoCities, the crap they wrap around
it makes it very invalid (though it seems to be still
'well formed' as far as I can tell by looking at it).
I grabbed the class and (a crude rendition* of what I
guess was) the original HTML, and put them here..
<http://www.physci.org/test/applet/002/>
If you can find any person that confirms that the
first URL breaks, but the second works, it can
be put down to 'crappy HTML' confusing the
browser.
(..yes, I realise your client has vanished into
thin air, but if they should ever pop by, ask
them to compare the two, I'd be interested in
hearing any problems with hosting applets off
the free sites..)
* I added a 'title' (because I like page titles), and a
character encoding - to make the validator 100% happy..
<http://validator.w3.org/check?uri=http%3A%2F%2Fwww.physci.org%2Ftest%2Fapplet%2F
002%2F>
Andrew T.
Arne Vajhøj - 21 Nov 2006 01:10 GMT
>> Make a call to System.getProperties(). That will return a properties
>> object that contains information about your environment. The
[quoted text clipped - 9 lines]
> exception: java.security.AccessControlException: access denied
> (java.util.PropertyPermission * read,write).
Try:
http://www.vajhoej.dk/arne/eksperten/showversion/showversion.html
The source are at:
http://www.vajhoej.dk/arne/eksperten/showversion/ShowVersion.java
Arne