Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Envrionment Variable & Properties

  1. #1
    Member
    Join Date
    Oct 2021
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Envrionment Variable & Properties

    I was doing a program asking the following: Write a Java program to get the value of the environment variable USERNAME.

    Si I wrote the following code :

    // getting username using System.getProperty in Java
            String user = System.getProperty("user.name");
            System.out.println(user); //print sid

    After checking solution of exercise they wrote the following code :

    // get the value of the specified environment variable USERNAME
            System.out.println(System.getenv("USERNAME")); // print null

    My question is what is the difference between environment variable and property?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Envrionment Variable & Properties

    Did you try asking with Google?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Oct 2021
    Posts
    63
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Re: Envrionment Variable & Properties

    I did but I want to have someone else explanation. I got my own understanding but it seems not that good since what I suggested as an answer (my code) is not correct

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Envrionment Variable & Properties

    What did you get from Google for explanations of those two areas?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Properties Proposal
    By noctarius in forum Java Theory & Questions
    Replies: 1
    Last Post: January 5th, 2013, 11:12 AM
  2. Reload .properties
    By chinna in forum Java Theory & Questions
    Replies: 3
    Last Post: July 14th, 2011, 01:32 AM
  3. Structured Properties File?
    By moka in forum Java Theory & Questions
    Replies: 7
    Last Post: October 19th, 2010, 11:14 AM
  4. Accessing Properties File
    By java_mein in forum Java Servlet
    Replies: 5
    Last Post: May 14th, 2010, 02:44 AM