Mock tests, Interview questions, Tutorials and Tech news
 
 

Archive

Posts Tagged ‘environment variables’

Use of environment variable in Java

June 20th, 2010 fanand No comments

In this post we will talk about environment variables in java , their role and how to use them in windows and Unix environment.

Reading environment Variables in Java

System environment variable can be used in the java application to set the system related values for ex: application path, database environment etc..,

In standalone application, start the JVM with the “-D” switch to pass properties to the application and read them with the System.getProperty() method.

SET myvar=Hello world

SET myothervar=nothing

java -Dmyvar=”%myvar%” -Dmyothervar=”%myothervar%” myClass

Then in myClass do the following

String myvar = System.getProperty(“myvar”);

String myothervar = System.getProperty(“myothervar”);

Read more…

Get Adobe Flash playerPlugin by wpburn.com wordpress themes