Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Cygwin and would like to modify the following PATH via bash shell:

/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Python33:/cygdrive/c/_WORK/java/jdk1.6.0_30/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/DLLShared:/cygdrive/c/Program Files (x86)/Common Files/Roxio Shared/10.0/DLLShared:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software/syswow64:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/Program Files (x86)/apache-ant-1.8.3/bin:/cygdrive/c/Program Files (x86)/Code Collaborator Client:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon

The path is huge.

Somewhere in the middle there is

What I'd like to do is to temporarily replace this with

In other words, I'd like to use different Java SDK versions. Sometimes I would use 1.6 sometimes 1.7.

How would I change the Java SDK path?

share|improve this question

closed as off-topic by MadHatter, Falcon Momot, Jenny D, dawud, Dave M Oct 2 '13 at 12:21

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 3 down vote accepted

Simply, customize the variable by running these commands:

export PATH

The new path will take precedence over the other one. To make this change permanent in your profile, put these two lines to the ~/.bash_profile or ~/.profile file.

Further, I would recommend to set the JAVA_HOME variable properly.

share|improve this answer

You can create a symbolic link

share|improve this answer
Thanks. Could you elaborate a little bit? Have in mind that the system is shared, so I cannot do much on my own. – Danijel Oct 2 '13 at 10:06

The way to handle different versions of the Java VM installed on your machine via cygwin is to register them in the alternatives system. Check its manpage for details.

This defines the system-wide default selected JRE/JDK.

To override this in a per-user environment, include JAVA_HOME in their .bash_profile.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.