No se puede establecer la variable PATH para jdk

I have installed sun-java in archlinux kde by first building the package and then installing it. This is the way the environment variables are set in my machine: file: /etc/profile # /etc/profile

#Set our umask
umask 022

# Set our default path
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
    for profile in /etc/profile.d/*.sh; do
        test -r "$profile" && . "$profile"
unset profile

# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc

# Termcap is outdated, old, and crusty, kill it.

# Man is much better than us at figuring this out

and file: /etc/profile.d/

export J2SDKDIR=/opt/java
export PATH=$PATH:/opt/java/bin:/opt/java/db/bin
export JAVA_HOME=/opt/java
export DERBY_HOME=/opt/java/db

what I understand from this is, jdk path should be set in the path environment variable but its not. But the attribute $JAVA_HOME is set correctly. Any reasons why am I facing this problem?

preguntado el 03 de mayo de 12 a las 20:05

In your PATH= /opt/java should go first other wise java installed in /usr/bin will be taken first. -

@geeky_sh what is the output of echo $PATH? -

echo $path /home/absolute/.rvm/gems/ruby1.9.3p0/bin:/home/absolute/.rvm/gems/ruby1.9.3p0@global/bin:/home/absolute/.rvm/rubies/ruby1.9.3p0/bin:/home/absolute/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl:/home/absolute/.rvm/bin -

@tigran there is no file named java found in /usr/bin -

wait, is it echo $PATH OR as you have written above echo $path. Variables in Linux/Unix/bash/ksh/etc_shell are case sensitive. make sure you're looking at the right variable. Please add a tag for the OS environment you are using, Linux,Unix,WindowsX. Also, it is better to edit your original question when answering a question about your environment, setup, inputs, expected output, and error messages. So, I'm advising you to edit your question to include output of echo $PATH. Buena suerte. -

2 Respuestas

/etc/profile and /etc/profile.d are processed only for login shells, so unless you're doing ssh into the machine where java is installed you won't get those variables.

To have them localmente (e.g. when you open an xterm on a workstation) put them in the file /etc/bash.bashrc.

Espero que esto ayude.

contestado el 04 de mayo de 12 a las 22:05

Actually, it was a silly mistake on my part. I am using zsh shell. So I was required to put:

    export PATH=$PATH:$JAVA_HOME/bin 

in .zshrc file instead of .bashrc.

contestado el 08 de mayo de 12 a las 18:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.