-1

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
c/_WORK/java/jdk1.6.0_30/bin.

What I'd like to do is to temporarily replace this with
c/_WORK/java/jdk1.7.0_40/bin

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?

Danijel
  • 256
  • 6
  • 19

3 Answers3

3

Simply, customize the variable by running these commands:

PATH="path_to_your_jdk_bin_dir:$PATH"
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.

dsmsk80
  • 5,817
  • 18
  • 22
1

You can create a symbolic link

Alon Kogan
  • 129
  • 4
  • 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 02 '13 at 10:06
0

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.

dawud
  • 15,096
  • 3
  • 42
  • 61