java path exporting - Redhat

This is a discussion on java path exporting - Redhat ; hi all, i am trying to figure out how to export java path. i am using fedor core 4 and modified my .bash_profile file correctly, i think. but still, the shell doesn't recognize javac command. i tried rebooting and checked ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: java path exporting

  1. java path exporting

    hi all,
    i am trying to figure out how to export java path. i am using fedor
    core 4 and modified my .bash_profile file correctly, i think. but
    still, the shell doesn't recognize javac command. i tried rebooting
    and checked typos and didn't find any.
    following shows what my .bash_profile is like.
    i would really appreciate it if anyone let me know what the problem is.

    thank you very much.

    -------------------
    [root@wuser59-shapiro jonghook]# cat /root/.bash_profile
    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi

    # User specific environment and startup programs

    JAVADIR = "jdk1.5.0_06"
    export JAVADIR
    PATH=/usr/java/$JAVADIR/bin:$PATH$HOME/bin:/sbin
    export PATH
    CLASSPATH=/usr/java/jdk1.5.0_06/lib/tools.jar:/usr/java/jdk1.5.0_06/jre/lib/rt.j
    ar:./
    export CLASSPATH

    unset USERNAME
    ----------------------


  2. Re: java path exporting

    On 19 Jan 2006 15:30:55 -0800, "thickface"
    wrote:

    >hi all,
    >i am trying to figure out how to export java path. i am using fedor
    >core 4 and modified my .bash_profile file correctly, i think. but
    >still, the shell doesn't recognize javac command. i tried rebooting
    >and checked typos and didn't find any.
    >following shows what my .bash_profile is like.
    >i would really appreciate it if anyone let me know what the problem is.
    >
    >thank you very much.
    >
    >-------------------
    >[root@wuser59-shapiro jonghook]# cat /root/.bash_profile
    ># .bash_profile
    >
    ># Get the aliases and functions
    >if [ -f ~/.bashrc ]; then
    > . ~/.bashrc
    >fi
    >
    ># User specific environment and startup programs
    >
    >JAVADIR = "jdk1.5.0_06"
    >export JAVADIR
    >PATH=/usr/java/$JAVADIR/bin:$PATH$HOME/bin:/sbin
    >export PATH
    >CLASSPATH=/usr/java/jdk1.5.0_06/lib/tools.jar:/usr/java/jdk1.5.0_06/jre/lib/rt.j
    >ar:./
    >export CLASSPATH
    >
    >unset USERNAME
    >----------------------


    Is "[...]$PATH$HOME[...]" (instead of something like
    "[...]$PATH:$HOME[...]") in your actual file, or just in this message?

  3. Re: java path exporting

    ....but more directly to the point, what do you see when you type "echo
    $PATH", and if you copy one of the directory names listed, and "cd"
    there, do you find javac?

  4. Re: java path exporting

    thickface wrote:

    > hi all,
    > i am trying to figure out how to export java path. i am using fedor
    > core 4 and modified my .bash_profile file correctly, i think. but
    > still, the shell doesn't recognize javac command. i tried rebooting


    Reconfiguring Fedora Core 4's default Java configuration

    This is done as root or equivalent.

    First remove /var/lib/alternatives/java file by typing;

    rm /var/lib/alternatives/java

    When asked press the 'y' key,

    Now to create the new (corrected) alternatives file for java type
    the following commands as root (modify for jdk as needed);

    /usr/sbin/alternatives --install /usr/bin/java
    java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1

    /usr/sbin/alternatives --install /usr/bin/java
    java /usr/java/j2re1.5.0_06/bin/java 2

    /usr/sbin/alternatives --config java

    You should now see for example:

    There are 2 programs which provide 'java'.

    Selection Command
    -----------------------------------------------
    1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
    *+ 2 /usr/java/j2re1.5.0_06/bin/java

    Enter to keep the current selection[+], or type selection number:

    Type:

    In the example above java is already configured correctly [*+ 2] to
    use Sun's Java, no changes are needed, just press the Enter key here.
    If you have been following the instructions then you should have
    the same results (version numbers may be sightly different).

    Now type; /usr/sbin/alternatives --display java

    You should see for example;

    java - status is manual.
    link currently points to /usr/java/j2re1.5.0_06/bin/java
    /usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1
    /usr/java/j2re1.5.0_06/bin/java - priority 2
    Current `best' version is /usr/java/j2re1.5.0_06/bin/java.

    Next you might want to create (or edit) /etc/profile.d/java.sh
    file, example below;

    export JAVA_HOME="/usr/java/jre1.5.0_06/bin"
    export JAVA_PATH="$JAVA_HOME"
    export PATH="$PATH:$JAVA_HOME"

    When done creating or editing the file type;

    source /etc/profile.d/java.sh

    Now any user root or other wise should be able to use the command;

    which java

    and the results should read something like;

    /usr/java/jre1.5.0_06/bin/java

    Also any user root or other wize should be able to use the command;

    java -version

    and the results should read something like;

    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)


    That's it, all done.


    --
    "A personal computer is called a personal computer because it's yours,
    Anything that runs on that computer, you should have control over."
    Andrew Moss, Microsoft's senior director of technical policy, 2005

+ Reply to Thread