• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to use the environment variables ?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When we use java to develop soft under win2000 , we always set some environment variables to cotroll the application program. For example , we always to set the CLASSPATH . Now I want to know are there any other environment variables specified by JVM ? what are these ? (Can you list these variables , thanks !) And can I define some environment variables by myself ?How can I use these environment variables defined by myself in the java application program ?
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To compile and run your java programs you don't need to set any other environment variable apart from CLASSPATH.
Earlier versions of Java support System.getenv("env_variable") to retrieve the value of Environment variables. This method is now deprecated.The preferred way to extract system-dependent information is the system properties of the java.lang.System.getProperty. You can define variables in a property file and use getProperty to retrive their values.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
chinese albert
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
 
Tom John
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Snigdha Solanki !
thank you for your answer .That make me clear very thing . But I have last questions obscurity.How to get the environment from a propertis files and how to set the environment for the system?

Originally posted by Snigdha Solanki:
To compile and run your java programs you don't need to set any other environment variable apart from CLASSPATH.
Earlier versions of Java support System.getenv("env_variable") to retrieve the value of Environment variables. This method is now deprecated.The preferred way to extract system-dependent information is the system properties of the java.lang.System.getProperty. You can define variables in a property file and use getProperty to retrive their values.

 
Snigdha Solanki
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the following code which retrieves the variables from properties file(properties.txt)


On running this program
java Test
Property Name is :John
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to read a environment variable you can on win32 use this:

on UNIX you can use this:

/Rene
[ July 10, 2002: Message edited by: Rene Larsen ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic