You are not logged in.

#1 2013-12-20 15:00:07

cbuehler
Member
Registered: 2013-12-20
Posts: 6

[SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

I am having a strange phanomenon.
I have jdk7-openjdk installed, but I still have

% echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk/jre

This is only with my current user. When I try root or a freshly created user, I correctly get

% echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk

So I guess this is caused by something in my home directory. As 'grep -r JAVA_HOME ~/.*' does not give any hints, I do not know how to investigate this further.

Maybe someone here has any idea how to find out more.

Last edited by cbuehler (2013-12-22 10:20:30)

Offline

#2 2013-12-20 17:58:23

ondoho
Member
Registered: 2013-04-30
Posts: 692
Website

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

welcome to archlinux!

cbuehler wrote:

Maybe someone here has any idea how to find out more.

search the wiki, the forums, the web.

Offline

#3 2013-12-20 18:42:24

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

JAVA_HOME is set by jre7-openjdk to /usr/lib/jvm/java-7-openjdk/jre. If one installs jdk7-openjdk, then it gets reset to /usr/lib/jvm/java-7-openjdk. If the JRE is installed first and then the JDK without the proper files being sourced, then JAVA_HOME doesn't get updated. By any chance did you install these seperately and not log off then back in again (or source the proper files)?

Last edited by skottish (2013-12-20 18:42:53)

Offline

#4 2013-12-20 23:21:42

cbuehler
Member
Registered: 2013-12-20
Posts: 6

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

@ondoho: Thanks, but I am not really new to Arch, only first post in the forum because I could not find anything useful by searching (mainly because I have no idea what to search for).
I am using Arch for several years, maintain some AUR packages etc. but until now did not have the need to post something on the forum.

@skottish: The installation happened a while ago, and I certainly did log off and on since then (e.g. this morning wink ). So I guess this should not be the issue.

Maybe someone can give me a hint how to trace when an environment variable gets set?

Offline

#5 2013-12-21 00:18:13

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

cbuehler wrote:

Maybe someone can give me a hint how to trace when an environment variable gets set?

/etc/profile.d/

Offline

#6 2013-12-21 00:45:18

cbuehler
Member
Registered: 2013-12-20
Posts: 6

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

% cat /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk
% cat /etc/profile.d/jre.sh
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk/jre}

# Enable this for non-reparenting window managers
#export _JAVA_AWT_WM_NONREPARENTING=1

But this does not explain why each user except mine are working as expected.

Offline

#7 2013-12-21 18:37:37

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

Are you using the same shell for your regular user as the others?

Offline

#8 2013-12-21 20:18:18

cbuehler
Member
Registered: 2013-12-20
Posts: 6

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

Yes, all use zsh as shell.

Offline

#9 2013-12-21 21:54:46

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

You should check exactly what is running /etc/profile.d/*, and how it is enforcing *alphabetical* order wink

Offline

#10 2013-12-22 01:20:37

cbuehler
Member
Registered: 2013-12-20
Posts: 6

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

% grep -r JAVA_HOME /etc/profile.d
/etc/profile.d/jre.csh:setenv JAVA_HOME "/usr/lib/jvm/java-7-openjdk/jre"
/etc/profile.d/jre.sh:export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk/jre}
/etc/profile.d/jdk.sh:export JAVA_HOME=/usr/lib/jvm/java-7-openjdk

Now I am completely confused: when I change the path in jdk.sh and log in again, JAVA_HOME has the new value. But when I restore the original path, the old behaviour is back (path to jre).

Offline

#11 2013-12-22 08:37:31

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

Please try to understand the difference between a *specified* order and a random order. This would completely explain what you're seeing, due to the definition of RANDOM.

E.g. I use:

for RC in `ls /etc/profile.d/*.{rc,sh}` ; do
    # Note we can set the permissions for root-specific scripts
    [ -r $RC ] && . $RC
done

And "man ls" says:

Sort entries alphabetically if none of ...

So that's how I get my sorting.

So I repeat, how do YOU ensure that your file processing order is not RANDOM?

Offline

#12 2013-12-22 10:16:53

cbuehler
Member
Registered: 2013-12-20
Posts: 6

Re: [SOLVED] Why does my JAVA_HOME point to jre instead of jdk?

As far as I understand, the order is not important in this case, because jre.sh only overrides JAVA_HOME if it is not set before.
I also like to avoid making configuration changes when it looks like the default config should work fine.

But brebs' reply inspired me to run 'sh -x /etc/profile', which finally shed light into my issue:

...
+++ . /home/cbuehler/Siemens/Teamcenter10.1/Visualization/bin/visviewwebinit /home/cbuehler/Siemens/Teamcenter10.1/Visualization
++++ '[' X_ = X_True ']'
++++ '[' -n /home/cbuehler/Siemens/Teamcenter10.1/Visualization ']'
++++ export EAI_INSTALL=/home/cbuehler/Siemens/Teamcenter10.1/Visualization
++++ EAI_INSTALL=/home/cbuehler/Siemens/Teamcenter10.1/Visualization
++++ '[' -d /usr/lib/jvm/java-7-openjdk/jre -o -h /usr/lib/jvm/java-7-openjdk/jre ']'
++++ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk/jre
++++ JAVA_HOME=/usr/lib/jvm/java-7-openjdk/jre
...

I have Teamcenter Visualization installed in my home directory. And this changes my JAVA_HOME in /home/cbuehler/Siemens/Teamcenter10.1/Visualization/bin/visviewwebinit:

# If JAVA_HOME points to the top level java directory, reset it to point to the JRE directory.
if [ -d $JAVA_HOME/jre -o -h $JAVA_HOME/jre ]; then
#{
    export JAVA_HOME=$JAVA_HOME/jre
#}
fi

I commented this part out and now everything works fine.

Thank you very much for your help.

Offline

Board footer

Powered by FluxBB