// SystemCheckApplet.java (c) Kari Laitinen // http://www.naturalprogramming.com // 2008-11-17 File created. // 2008-11-17 Latest modification. /* This program shows how an applet can find out the properties of the Java Runtime Environment where it is being executed. In both Java-enabled browsers and the appletviewer, applets can read these system properties by invoking the System.getProperty( String key ) method: Key Meaning ____________ ______________________________ java.version Java version number java.vendor Java vendor-specific string java.vendor.url Java vendor URL java.class.version Java class version number os.name Operating system name os.arch Operating system architecture os.version Operating system version file.separator File separator (eg, "/") path.separator Path separator (eg, ":") line.separator Line separator Applets are prevented from reading these system properties: Key Meaning ____________ _____________________________ java.home Java installation directory java.class.path Java classpath user.name User account name user.home User home directory user.dir User's current working directory */ import java.awt.* ; import javax.swing.JApplet ; public class SystemCheckApplet extends JApplet { public void paint( Graphics graphics ) { super.paint( graphics ) ; int text_position_x = 40 ; int text_position_y = 50 ; graphics.setFont( new Font( "monospaced", Font.BOLD, 14 ) ) ; graphics.drawString( "Properties of your Java Runtime Environment: ", text_position_x, text_position_y ) ; graphics.drawString( "Java version number " + System.getProperty( "java.version" ), text_position_x + 20, text_position_y + 30 ) ; graphics.drawString( "Java vendor " + System.getProperty( "java.vendor" ), text_position_x + 20, text_position_y + 50 ) ; graphics.drawString( "Java vendor URL " + System.getProperty( "java.vendor.url" ), text_position_x + 20, text_position_y + 70 ) ; graphics.drawString( "Java class version number " + System.getProperty( "java.class.version" ), text_position_x + 20, text_position_y + 90) ; graphics.drawString( "Operating system name " + System.getProperty( "os.name" ), text_position_x + 20, text_position_y + 110 ) ; graphics.drawString( "Operating system architecture " + System.getProperty( "os.arch" ), text_position_x + 20, text_position_y + 130 ) ; graphics.drawString( "Operating system version " + System.getProperty( "os.version" ), text_position_x + 20, text_position_y + 150 ) ; graphics.drawString( "File separator " + System.getProperty( "file.separator" ), text_position_x + 20, text_position_y + 170 ) ; graphics.drawString( "Path separator " + System.getProperty( "path.separator" ), text_position_x + 20, text_position_y + 190 ) ; graphics.drawString( "Line separator " + System.getProperty( "line.separator" ), text_position_x + 20, text_position_y + 210 ) ; } }