Different from applet, the application does not have an automatically installed security manager. By default, the application has full permissions. Create an application to obtain the system property value.
/*
* @ (#) Getsysprop. Java 1.0 06/08/07
* Get the System Properties
* Jiazhen 2006.08.07
*/
Import java. Security .*;
Class getsysprop
{
Public static void main (string ARGs []) {
String S;
Try {
// The default returned string is not specified.
// Obtain the system name
S = system. getproperty ("OS. Name", "not specified ");
System. Out. println ("the name of your operating system is:" + S );
// Obtain the Java Virtual Machine version
S = system. getproperty ("Java. Version", "not specified ");
System. Out. println ("your user home directory is:" + S );
// Obtain the user path
S = system. getproperty ("USR. Home", "not specified ");
System. Out. println ("your user home directory is:" + S );
// Obtain java_home
S = system. getproperty ("Java. Home", "not specified ");
System. Out. println ("Your JRE installation directory is:" + S );
}
Catch (exception e ){
E. printstacktrace ();
}
}
}
The Java policy file does not authorize all system attributes. When the program reads the system attributes that are not authorized, an exception is thrown. To obtain access permissions for certain system attributes, you can create a policy file by yourself.