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 3 of 3

Thread: Windows 7 Environment Variables out of sync

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,619
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Windows 7 Environment Variables out of sync

    I am having a very weird issue with Windows 7, and I'd like ideas. I appear to be having some sort of sync issue with my environment variables.
    So I recently changed from Apache Maven 3.0.5 to 3.0.3 (work required it).
    The previous maven folder was located at:
    C:\...\apache-maven-3.0.5
    The new one is located in the same place, and 3.0.5 version was deleted:
    C:\...\apache-maven-3.0.3

    Maven requires 2 environment variables to be set: a M2_HOME variable, and then an added PATH variable: M2_HOME\bin
    I adjusted my M2_HOME variable accordingly, and left the PATH variable alone, since it is just referencing the M2_HOME.

    Ok, so when I log into my computer, if I open a command prompt and type:
    mvn -version
    I get the standard:
    'mvn' is not recognized as an internal or external command, operable program or batch file.
    If I then type:
    echo %M2_HOME%
    It replies with the new correct directory:
    C:\...\apache-maven-3.0.3
    If I then check my PATH variable:
    echo %PATH%
    It prints (among the rest of the paths) the OLD and non-existent maven folder:
    C:\...\apache-maven-3.0.5\bin

    And as if that all wasn't weird enough, to "fix" the problem, all I have to do is go to my environment variables, open the edit for the PATH variable, and then immediately close it without changing or saving anything. After I do that, my echo of the PATH variable is suddenly correct:
    C:\...\apache-maven-3.0.3\bin
    And everything works properly.

    Another solution is opening up the command prompt in Administrator mode. If I do an echo of the PATH variable then, I get the correct variable:
    C:\...\apache-maven-3.0.3\bin
    If I then open the command prompt normally (not in Admin mode), it is still in its "broken" state.

    To revert the PATH variable back to its broken state, all I have to do is log out of my account, and then log back in (no need to even turn the pc off, just logging out does it).

    Does anyone have a clue what the heck is going on here?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Junior Member
    Join Date
    Apr 2014
    Posts
    15
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default Re: Windows 7 Environment Variables out of sync

    Not sure if it helps, but in case you have 64bit OS, you could look at the task manager to see if the working cmd is running in 32bit mode or 64.
    Do you have the M2_HOME variable in "system properties" or "user properties"?
    Do you do the full pc restart after making change? or just logoff -> login? (I always restart my pc to be sure)

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,619
    Thanks
    25
    Thanked 322 Times in 300 Posts

    Default Re: Windows 7 Environment Variables out of sync

    I found the problem. The registry values had not updated with the new path. So every time I logged in, the system variables were loaded from the registry, which had the wrong values. When I opened the edit environmental variables window, the currently loaded values in memory were updated to reflect what was in the window.
    That's why the problem came back on startup and why simply opening that window solved the problem.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Sync movement with sound?
    By cl2606 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 2nd, 2011, 05:12 PM
  2. Force Sync on Graphics2D?
    By Gerp in forum Java Theory & Questions
    Replies: 2
    Last Post: April 13th, 2011, 09:13 PM
  3. Java swing buttons are flickering in windows 7 environment
    By javasam in forum Member Introductions
    Replies: 1
    Last Post: February 17th, 2011, 08:51 AM
  4. Java swing buttons are flickering in windows 7 environment
    By javasam in forum AWT / Java Swing
    Replies: 1
    Last Post: February 14th, 2011, 11:13 AM
  5. sync two diffrent kind of threads?
    By adamruss in forum Threads
    Replies: 1
    Last Post: January 10th, 2010, 07:59 PM