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

Re: User level alternatives?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Florian Kulzer wrote:
> 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
> 

You are right. Here for me:
$ ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 34 2007-04-11 21:16 /etc/alternatives/java ->
/usr/lib/jvm/java-gcj/jre/bin/java
$ ls -l /usr/lib/jvm/java-gcj/jre/bin/java
lrwxrwxrwx 1 root root 26 2007-02-04 02:04
/usr/lib/jvm/java-gcj/jre/bin/java -> ../../../../../bin/gij-4.1


> 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.)
> 

That is what exactly I do now.

> 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.
> 


- --
Cheers,

Wei Chen
http://www.acplex.com/people/wchen/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGKgDXCIqXQV6BF28RAjiuAKCX2VOEnZ3TOi4AOCJ4lL79nKL7TwCgnyb5
HlpbDor+U+fgBtxrCQZBEYs=
=mXFK
-----END PGP SIGNATURE-----



Reply to: