[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: User level alternatives?



On Sat, Apr 21, 2007 at 13:59:41 +0800, Wei Chen wrote:
> 
> Douglas Allan Tutty wrote:
> > On Fri, Apr 20, 2007 at 07:26:37PM +0800, Wei Chen wrote:
> >> We now have system level `update-alternatives' mechanism that can be
> >> used by root to maintain symbol links in `/etc/alternatives'. Is it
> >> useful/interesting to extend its use to user level, i.e. to maintain
> >> similar symbol links in `~/bin' or something like `~/bin/alternatives'?
> >> Or does that already exist? I personally think it can be useful, because
> >> I currently do that manually.
> > 
> > Just set aliases in your .bash_aliases file.
> > 
> 
> That is not always convenient. I want to switch between gcj's VM and
> compiler and sun's for one account. The names of the executables are the
> same, i.e. `java' and `javac'.

No, they are not. Just follow the symlinks:

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2007-03-18 13:20 /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 24 2007-03-18 13:20 /etc/alternatives/java -> /usr/bin/gij-wrapper-4.1
$ file /usr/bin/gij-wrapper-4.1
/usr/bin/gij-wrapper-4.1: perl script text executable

If you select Sun's JVM via the alternatives system then the
/etc/alternatives/java symlink will simply be pointing to another
executable.

As Douglas has suggested, you could define aliases for "java" etc. which
translate to the real executables, e.g.

alias java='/usr/bin/gij-wrapper-4.1'

You could also create your own ~/alternatives directory, add it as the
first element of your $PATH and put a symlink there, like so:

$ which java
/usr/bin/java
$ ln -s /bin/date ~/.bin/java
$ which java
/home/florian/.bin/java
$ java
Sat Apr 21 13:22:05 CEST 2007

(I have ~/.bin in my $PATH for my own scripts.)

Of course you can also just type /usr/bin/gij-wrapper-4.1 explicitly on
the command line to make sure which JVM is used.

-- 
Regards,            | http://users.icfo.es/Florian.Kulzer
          Florian   |



Reply to: