Browsed by
Month: October 2012

Environment Variables In Java

Environment Variables In Java

  Environment Variables  are variables that are added in any Operating system that can be accessed from anywhere in OS without using the complete(Real) location.   In a java Application System.getenv(); is used to find out the system environment variables Example:- import java.util.Map; public class EnvMap { public static void main (String[] args) { Map<String, String> env = System.getenv(); for (String envName : env.keySet()) { System.out.format(“%s=%s%n”, envName, env.get(envName)); } } }  

Security Manager in Java

Security Manager in Java

A security manager is an object that is used to check whether the operation we want to perform is not violating the security policy of the operating system. Sometimes we want to perform any operation and get an exception Exception in thread “AWT-EventQueue-1” java.security.AccessControlException: access denied (java.io.FilePermission characteroutput.txt write) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkWrite(SecurityManager.java:962) at java.io.FileOutputStream.<init>(FileOutputStream.java:169) at java.io.FileOutputStream.<init>(FileOutputStream.java:70) at java.io.FileWriter.<init>(FileWriter.java:46) To Prevent this exception we can use SecurityManager class to check for the permission before performing an operation….

Read More Read More

System Properties in java

System Properties in java

There are various system properties that we can use in our programs to perform some action or access some file.There are some commonly used properties.   Key Meaning “file.separator” Character that separates components of a file path. This is “/” on UNIX and “” on Windows. “java.class.path” Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. “java.home” Installation directory for Java Runtime Environment (JRE) “java.vendor” JRE…

Read More Read More