Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Windows Service Pack Version from Java Applet?

I am writing a Java Applet. When run on Windows, I need to be able to get the clients OS version, e.g. Windows XP SP3 or Windows 2000 SP4.

I can currently use the following:

String os_name    = System.getProperty( "os.name" );
String os_version = System.getProperty( "os.version" );

System.out.println( "Running on " + os_name + "(" + os_version + ")" );

And it will output something like "Running on Windows 2000 (5.0)" which is great but I need to be able to get the service pack version too.

Anybody know how I can get the underlying service pack version of a Windows machine from within a Java applet? (Without throwing an AccessControlException, or ideally without having to self sign the applet).

Many thanks in advance.

like image 574
QAZ Avatar asked Nov 17 '25 00:11

QAZ


1 Answers

You can self-sign your java applet:

(stolen from: http://www.captain.at/programming/java/)

Make the certificate:

keytool -export -alias yourkey -file yourcert.crt

Now we have to sign the applet:

Just make a *.bat file including this:

javac yourapplet.java
jar cvf yourapplet.jar yourapplet.class
jarsigner yourapplet.jar yourkey

The batch-file compiles the applet, makes a jar-archive and signs the jar-file.

The HTML-code to display the applet:

<applet code="yourapplet.class" archive="yourapplet.jar" width="600"

height="500">

Now we are done! The applet is signed and if the user accepts the certificate, the applet is allowed to access local files. If the user doesn't agree, you get a java.security.AccessControlException.

So, as long as you don't mind about this little dialog box...

like image 179
bgw Avatar answered Nov 19 '25 14:11

bgw