Java application default permissions (simple example)

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.