Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Where do the Java environment variables come from and how do I have them get set correcty?

  1. #1
    Join Date
    Dec 2009
    Location
    Zurich
    Posts
    15

    Default Where do the Java environment variables come from and how do I have them get set correcty?

    I installed the latest Oracle Java sdk onto my new openSUSE 12.3 environment. I updated the update alternatives thing but the environment variables don't follow suite. Sure I could set the variables manually with a script every time I start a java app but if they are in the env without my having done anything, can I at least have them come correctly?

    me@host:~> env | grep -i java
    JRE_HOME=/usr/lib64/jvm/java-1.5.0/jre
    JAVA_BINDIR=/usr/lib64/jvm/java-1.5.0/bin
    JAVA_HOME=/usr/lib64/jvm/java-1.5.0
    SDK_HOME=/usr/lib64/jvm/java-1.5.0
    JDK_HOME=/usr/lib64/jvm/java-1.5.0
    JAVA_ROOT=/usr/lib64/jvm/java-1.5.0


    What I did to set up the Oracle java:
    /usr/sbin/update-alternatives --install /usr/bin/java java /usr/local/jdk1.7.0_17/bin/java 1
    /usr/sbin/update-alternatives --install "/usr/lib64/browser-plugins/javaplugin.so" "javaplugin" "/usr/local/jdk1.7.0_17/jre/lib/amd64/libnpjp2.so" 20000
    /usr/sbin/update-alternatives --set java /usr/local/jdk1.7.0_17/bin/java
    /usr/sbin/update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.7.0_17/bin/javac 1


    me@host:~> which java
    /usr/bin/java

    me@host:~> ls -l /usr/bin/java
    lrwxrwxrwx 1 root root 22 Mar 18 22:04 /usr/bin/java -> /etc/alternatives/java

    me@host:~> ls -l /etc/alternatives/java
    lrwxrwxrwx 1 root root 31 Mar 19 20:58 /etc/alternatives/java -> /usr/local/jdk1.7.0_17/bin/java




    me@host:~> cat .profile
    # Sample .profile for SuSE Linux
    # rewritten by Christian Steinruecken <cstein@suse.de>
    #
    # This file is read each time a login shell is started.
    # All other interactive shells will only read .bashrc; this is particularly
    # important for language settings, see below.


    test -z "$PROFILEREAD" && . /etc/profile || true


    # Most applications support several languages for their output.
    # To make use of this feature, simply uncomment one of the lines below or
    # add your own one (see /usr/share/locale/locale.alias for more codes)
    # This overwrites the system default set in /etc/sysconfig/language
    # in the variable RC_LANG.
    #
    #export LANG=de_DE.UTF-8 # uncomment this line for German output
    #export LANG=fr_FR.UTF-8 # uncomment this line for French output
    #export LANG=es_ES.UTF-8 # uncomment this line for Spanish output




    # Some people don't like fortune. If you uncomment the following lines,
    # you will have a fortune each time you log in ;-)


    #if [ -x /usr/bin/fortune ] ; then
    # echo
    # /usr/bin/fortune
    # echo
    #fi




    me@host:~> cat .bashrc
    # Sample .bashrc for SuSE Linux
    # Copyright (c) SuSE GmbH Nuernberg


    # There are 3 different types of shells in bash: the login shell, normal shell
    # and interactive shell. Login shells read ~/.profile and interactive shells
    # read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
    # settings made here will also take effect in a login shell.
    #
    # NOTE: It is recommended to make language settings in ~/.profile rather than
    # here, since multilingual X sessions would not work properly if LANG is over-
    # ridden in every subshell.


    # Some applications read the EDITOR variable to determine your favourite text
    # editor. So uncomment the line below and enter the editor of your choice :-)
    #export EDITOR=/usr/bin/vim
    #export EDITOR=/usr/bin/mcedit


    # For some news readers it makes sense to specify the NEWSSERVER variable here
    #export NEWSSERVER=your.news.server


    # If you want to use a Palm device with Linux, uncomment the two lines below.
    # For some (older) Palm Pilots, you might need to set a lower baud rate
    # e.g. 57600 or 38400; lowest is 9600 (very slow!)
    #
    #export PILOTPORT=/dev/pilot
    #export PILOTRATE=115200


    test -s ~/.alias && . ~/.alias || true
    richi@zwirgli:~>





    My guess is that it's with the script /etc/profile.d/alljava.csh . But shouldn't this look at the "alternative" symlinks?

    Regards,
    Richard

  2. #2
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 2013-03-23 18:36, richardeigenmann wrote:
    >
    > I installed the latest Oracle Java sdk onto my new openSUSE 12.3
    > environment. I updated the update alternatives thing but the environment
    > variables don't follow suite. Sure I could set the variables manually
    > with a script every time I start a java app but if they are in the env
    > without my having done anything, can I at least have them come
    > correctly?
    >
    > me@host:~> env | grep -i java
    >
    > JRE_HOME=/usr/lib64/jvm/java-1.5.0/jre
    > JAVA_BINDIR=/usr/lib64/jvm/java-1.5.0/bin
    > JAVA_HOME=/usr/lib64/jvm/java-1.5.0
    > SDK_HOME=/usr/lib64/jvm/java-1.5.0
    > JDK_HOME=/usr/lib64/jvm/java-1.5.0
    > JAVA_ROOT=/usr/lib64/jvm/java-1.5.0



    In my system, these do not even exist. I don't know who should create
    them, and contents.

    >
    >
    > What I did to set up the Oracle java:


    I simply install the oracle rpm. It does not go to /usr/local/, but to
    "/usr/java/jre1.7.0_17".

    > My guess is that it's with the script /etc/profile.d/alljava.csh . But
    > shouldn't this look at the "alternative" symlinks?


    That script is for cshell only. I figure that as java is not in the
    usual location, the variables are not set.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  3. #3
    dd NNTP User

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 03/23/2013 06:36 PM, richardeigenmann wrote:
    > I installed the latest Oracle Java sdk onto my new openSUSE 12.3
    > environment.


    yep, imo one has to be a little lucky to get it right (Carlos was
    born lucky!)

    the last time i got it right i followed this
    guide:http://sites.google.com/site/easylin...a-for-opensuse

    i really dislike not having a fool proof guide on a page among the
    [whatever].opensuse.org but, that one worked for me, on openSUSE 11.4
    Evergreen

    --
    dd
    http://tinyurl.com/DD-Caveat
    http://tinyurl.com/DD-Software

  4. #4
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 2013-03-24 01:17, dd wrote:
    > On 03/23/2013 06:36 PM, richardeigenmann wrote:
    >> I installed the latest Oracle Java sdk onto my new openSUSE 12.3
    >> environment.

    >
    > yep, imo one has to be a little lucky to get it right (Carlos was born
    > lucky!)


    X'-)

    >
    > the last time i got it right i followed this
    > guide:http://sites.google.com/site/easylin...a-for-opensuse


    Those are the instructions I followed :-)

    Except that I deviate from them in that instead of the .tar.gz I use the
    ..rpm from the same oracle site.

    > i really dislike not having a fool proof guide on a page among the
    > [whatever].opensuse.org but, that one worked for me, on openSUSE 11.4
    > Evergreen


    I used the same method both on my 11.4 and 12.1. Let's see my notes.
    The first thing is removing the original Sun rpm that openSUSE 11.4 or
    12.1 had. Yast will then install instead another java version, icetea or
    whatever. This has to be allowed, because otherwise YaST will think that
    there is no java installed and will then try to remove things like
    LibreOffice.

    So we need having two Java installations, one from Oracle (which
    openSUSE does not "recognize"), and any other one that YaST does
    recognize - even if you will not use it. So its life. :-)


    Thus download the Oracle rpm, currently "jre-7u17-linux-x64.rpm". Then
    install it, with (from the directory where it is downloaded, in a
    terminal as root:

    Code:
    rpm --install jre-7u17-linux-x64.rpm
    And on the next version, you do instead:

    Code:
    rpm --upgrade jre-7u18-linux-x64.rpm
    and you are finished, you don't need to do anything else.


    But the first time, you need using "update-alternatives":

    Code:
    
    > Telcontar:~ # l /usr/bin/java
    > lrwxrwxrwx 1 root root 22 Aug 21  2012 /usr/bin/java -> /etc/alternatives/java*
    > Telcontar:~ # l /etc/alternatives/java
    > lrwxrwxrwx 1 root root 26 Aug 21  2012 /etc/alternatives/java -> /usr/java/default/bin/java*
    > Telcontar:~ # l /usr/java/default/bin/java
    > -rwxr-xr-x 1 root root 7750 Mar  1 12:30 /usr/java/default/bin/java*
    > Telcontar:~ # rpm -qf /usr/java/default/bin/java
    > jre-1.7.0_17-fcs.x86_64
    > Telcontar:~ #
    
    > Telcontar:~ # update-alternatives --install "/usr/bin/java" "java" "/usr/java/default/bin/java" 1
    > Telcontar:~ # update-alternatives --set java /usr/java/default/bin/java
    > Telcontar:~ # update-alternatives --list java
    > /usr/java/default/bin/java
    > /usr/lib64/jvm/jre-1.6.0-openjdk/bin/java
    > Telcontar:~ #
    
    (I think the '1' above is because of the first line in --list - I don't
    remember)
    
    Then check:
    
    > Telcontar:~ # java -version
    > java version "1.7.0_17"
    > Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
    > Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
    > Telcontar:~ #


    Apparently, that's all. It works, my java applications run. Mozilla test
    is ok, too. You also need to do, for every user, this - if you want java
    in firefox:


    Code:
    ln -s /usr/java/default/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
    I think that there is another method that would work for every user at
    once, but I don't know it.


    The remaining problem I have is this, apparently:

    Code:
    Telcontar:~ # env | grep -i java
    Telcontar:~ #
    And about this one I'm not sure what i should do, if anything. :-?

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  5. #5
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 2013-03-24 02:33, Carlos E. R. wrote:
    >
    Code:
    > rpm --upgrade jre-7u18-linux-x64.rpm
    >
    >
    > and you are finished, you don't need to do anything else.


    I forgot, there is one gotcha. The init script "/etc/init.d/jexec" has
    an error, which you notice when you insert the script. It has this section:


    Code:
    ### BEGIN INIT INFO
    # Provides: binfmt_misc
    # Required-Start: $local_fs
    # Default-Start: 1 2 3 4 5
    # Default-Start: 0 6
    # chkconfig: 12345 95 05
    # Description: Supports the direct execution of binary formats.
    ### END INIT INFO
    should be this:

    Code:
    ### BEGIN INIT INFO
    # Provides: binfmt_misc
    # Required-Start: $local_fs
    # Required-Stop:
    # Default-Start: 1 2 3 4 5
    # Default-Stop: 0 6
    # chkconfig: 12345 95 05
    # Description: Supports the direct execution of binary formats.
    ### END INIT INFO
    The "Required-Stop" is missing, and the second "Default-Start" is in
    fact the "Default-Stop" section. This is a bug that has been there for
    YEARS and Sun/Oracle has not bothered to correct. And it is an easy
    one... one has to imagine what else that one does not know is hiding
    somewhere.


    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  6. #6
    Join Date
    Dec 2009
    Location
    Zurich
    Posts
    15

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    I have decided to create a script to correct the references:

    Code:
    me@host:~> cat /richi/Src/Scripts/java-env.sh
    JAVA_HOME=/usr/local/jdk1.7.0_17
    JRE_HOME=$JAVA_HOME/jre
    JAVA_BINDIR=$JAVA_HOME/bin
    SDK_HOME=$JAVA_HOME
    JDK_HOME=$JAVA_HOME
    JAVA_ROOT=$JAVA_HOME

    And this is what I have in my environment after a

    Code:
    source /richi/Src/Scripts/java-env.sh

    Code:
    me@host:/richi/Src/Jpo> env | egrep -i "java|jdk|sdk"
    JRE_HOME=/usr/local/jdk1.7.0_17/jre
    JAVA_BINDIR=/usr/local/jdk1.7.0_17/bin
    JAVA_HOME=/usr/local/jdk1.7.0_17
    SDK_HOME=/usr/local/jdk1.7.0_17
    JDK_HOME=/usr/local/jdk1.7.0_17
    JAVA_ROOT=/usr/local/jdk1.7.0_17
    Regards,
    Richard

  7. #7
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 2013-03-24 19:36, richardeigenmann wrote:
    > I have decided to create a script to correct the references:


    Put it inside your local .profile file, that's it purpose. Or create an
    "/etc/profile.d/alljava.bash" file.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

  8. #8

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    Hi,
    I found your thread while determining how I should install Java. I found a gazillion ways googling.

    This link might help: Support | How to manually install Oracle Java into SLED 11 SP1/2
    The last part says:
    As some scripts expects JAVA_HOME variable, you can add the following the following lines to the file /etc/profile.d/zzz-oracle-java.sh:

    export JAVA_HOME=/usr/java/latest
    export JAVA_ROOT=/usr/java/latest
    export JAVA_BINDIR=/usr/java/latest/bin
    export JRE_HOME=/usr/java/latest
    This is a bug discussion on alljava.sh here: https://bugzilla.novell.com/show_bug.cgi?id=722252

    It looks like you are on the right track.

  9. #9

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    Hi,

    I did have some other comments and concerns, mostly about update-alternatives (UA). Is it needed at all? It seems the system could be kept as-is and set the variables for anything else. And Netbeans has its own options to add and remove java versions. But if you opt to change java for the system, how do you determine what files?

    A handy bash way to look at the JAVA variables (the output can be used in your .bashrc w/appropriate file changes):
    Code:
    declare -p ${!J@}; declare -p ${!SD@}
    Searching the net, I've seen many variations of UA. It varies from none, to just java and javac, to everything (java related) with/without slaves. One user just changed to the /usr/local/jdk1.7.0_17 directory and did a:
    Code:
    for f in *; do update-alternatives --install /usr/bin/$f $(pwd)/$f 40; done
    I looked at:
    Code:
    update-alternatives --get-selections
    Took the results and looked for master names that were located in /usr/lib64, like java, javac, javaplugin, javadocdir, etc, and did (for each):
    Code:
    update-alternatives --query java
    I thought I could construct a reasonable UA command with the above info. But does it really matter if they are slaves in a link group or just all master links. This is a manual install. The next release of java will be installed in its own directory and this process repeated. So the above command kind of makes sense. I think it isn't complete though because it only hits the bin directory. It misses the man pages.

    Thank you.

  10. #10
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Where do the Java environment variables come from and how doI have them get set correcty?

    On 2013-03-26 07:56, opensuseforumorg42 wrote:
    > This is a manual install. The next release of
    > java will be installed in its own directory and this process repeated.


    Nope.

    If you use the java rpm for installation and upgrades, you do those
    customizations just the first time.

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 12.1 x86_64 "Asparagus" at Telcontar)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •