LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add to PATH (bash) for All Users (Suse) (https://www.linuxquestions.org/questions/linux-newbie-8/add-to-path-bash-for-all-users-suse-663217/)

davidstvz 08-16-2008 03:15 PM

I tried YaST, but it's a dependency nightmare in there.

I might try just copying all of those links to different location ... or maybe tarball and delete them.

Err, how do you move a link? I tried to copy it but it copied the link targets instead.

EDIT:

I just noticed that *everything* in this alternatives folder is java related (related to 1.4.2). I'm going to try renaming this folder.

davidstvz 08-16-2008 03:28 PM

Well, that did it :)

Pretty dirty hack really, but it's easy to fix if it broke anything.

colucix 08-16-2008 03:57 PM

You may be interested in this document from the OpenSuSE wiki. Look at the last section called "Switching between two different Java JREs or SDKs".

Regarding the PATH issue, the java executable is not in the system PATH, or better - as already pointed out by arizonagroovejet - it uses the /etc/alternatives system. However if you do
Code:

$ which java
you will notice that the java executable is found in /usr/bin and
Code:

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2007-10-15 14:58 /usr/bin/java -> /etc/alternatives/java

tells you that java is a link to the java in /etc/alternatives, which is another link to the real executable installed by the java RPM.

In a more general context, the system wide PATH environment variable in most system (OpenSuSE included) is set in /etc/profile plus the scripts in /etc/profile.d directory. If you look at the code in /etc/profile you will see the statements used to set the PATH plus the following piece of code:
Code:

#
# Source profile extensions for certain packages
#
if test -d /etc/profile.d -a -z "$PROFILEREAD" ; then
    for s in /etc/profile.d/*.sh ; do
        test -r $s && . $s
    done
    unset s
fi

this means: if /etc/profile.d exists and is a directory, for every file .sh in /etc/profile.d test if read permissions are granted and source it (that is include its code in the current shell). Usually the scripts in /etc/profile.d add one or more directory to the PATH and set other environment variables as MANPATH, LD_LIBRARY_PATH and other specific to the software which installed them.

Hope it is a little more clear, now! :)

davidstvz 08-16-2008 04:10 PM

OK, that's a lot more clear.

In suse there is a csh and an sh entry for each script in /etc/profile.d/

My students will use bash, so I guess that's the .sh entry?

colucix 08-16-2008 04:13 PM

Quote:

Originally Posted by davidstvz (Post 3249992)
My students will use bash, so I guess that's the .sh entry?

Yes. Files .csh are for C-shells (csh, tcsh).

davidstvz 08-16-2008 04:40 PM

I just set all the paths in that alljava.sh file manually (took at all the scripting and hard coded it) and moved the alternatives back were they were, and it's running 1.4.2_16 again. Should left well enough alone :)

In other words it's broken.

davidstvz 08-16-2008 04:48 PM

Here's what I put in alljava.sh

I'm going to move it into the bash.bashrc.local for now (minus the exports)

export JAVA_BINDIR=/usr/java/default/bin
export JAVA_ROOT=/usr/java/default/
export JAVA_HOME=/usr/java/default/
export JRE_HOME=/usr/java/default/jre
export JDK_HOME=/usr/java/default/
export SDK_HOME=/usr/java/default/


All times are GMT -5. The time now is 10:54 PM.