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

An aside on having . in PATH, Re: no JAVA_HOME in the path



On Tue 23 Aug 2022 at 16:33:40 (+0200), rudu wrote:
> On 2022-08-23 9:40 a.m., Roberto C. Sánchez wrote:
> > > On Tue, Aug 23, 2022 at 09:21:38AM -0400, Amn wrote:
> > > >     When I type echo $JAVA_HOME, Debian 11's Konsole
> > > > displays ... nothing,
> > > >     'echo $PATH' reports -
> > > > /usr/local/[1]bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:libtool:
> > > >     /usr/bin/libtool /usr/share/libtool
> > > > /usr/share/man/man1/libtool.1.gz -
> > > >     However if I type, 'java --version' I get -
> > > > /usr/local/[2]bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:libtool:
> > > >     /usr/bin/libtool /usr/share/libtool
> > > > /usr/share/man/man1/libtool.1.gz -,
> > > >     which is correct.
> > > >     Where is $JAVA_HOME set or how do I add it to the path permanently?
> > > > 
> > > You have to set it yourself.
> > > 
> > > Options include /etc/bashrc, /etc/profile, /etc/profile.d,
> > > /etc/environment, /etc/environment.d, and possibly others, for setting
> > > it system-wide, and their per-user counterparts in $HOME for setting it
> > > on a per-user basis.
> > > 
> > > Regards,
> > > 
> > > -Roberto
> > > 
> > 
> > Le 23/08/2022 à 15:49, Amn a écrit :
> > > Thank you for your prompt response.
> > > Adding Java to the $PATH variable requires me to know the
> > > location where Java was installed, which I don't know. Is
> > > there a way to find out where Java was installed?
> > > 
> > > 
> 
> Maybe this could help :
> 
> $ java -version
> openjdk version "11.0.16" 2022-07-19
> OpenJDK Runtime Environment (build 11.0.16+8-post-Debian-1)
> OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Debian-1, mixed mode,
> sharing)
> 
> $ update-alternatives --config java
> Il existe 6 choix pour l'alternative java (qui fournit /usr/bin/java).
> 
>   Sélection   Chemin Priorité  État
> ------------------------------------------------------------
>   0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111     
> mode automatique
>   1            /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53        mode
> manuel
>   2            /usr/lib/jvm/java-10-openjdk-amd64/bin/java 1101     
> mode manuel
> * 3            /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111     
> mode manuel
>   4            /usr/lib/jvm/java-6-sun/jre/bin/java 63        mode manuel
>   5            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
> 1081      mode manuel
>   6            /usr/lib/jvm/oracle-java8-jdk-amd64/jre/bin/java
> 318       mode manuel
> 
> Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou
> choisissez le numéro sélectionné :
> 
> (Sorry, it's french)

Not as bad as the OP's use of HTML. I've looked at that post in its
text version, the raw HTML, as rendered by lynx, and in firefox,
and it looks as though the PATH ends with a colon.

So I'll just point out that if you want the current directory in
your PATH, then make it explicit with a period, as in:

  … … …games:/usr/games:/snap/bin:libtool:.

and if you don't, then remove the final colon, as in:

  … … …games:/usr/games:/snap/bin:libtool

If ever you want to run, say, foo in your current directory,
then just type:

$ ./foo

But in view of the newish semantics for su, I'd strongly advise
against having PATH include the directory that you just happened
be in at the moment.

Cheers,
David.


Reply to: