From: laredotornado on
Hi,

I'm using Mac 10.5.6. I have just installed a version of JBoss that
relies on Java 1.6, and therefore, requires you to set JAVA_HOME to
point to the Java 1.6 install directory. However, currently JAVA_HOME
is pointing to a 1.5 installation, and I would like to keep it that
way because I have some other apps that rely on Java 1.5. Is there a
way I can define JAVA_HOME only for scripts run within a certain
directory (namely, the JBoss installation)?

Thanks for any thoughts, - Dave
From: Janis Papanagnou on
laredotornado wrote:
> Hi,
>
> I'm using Mac 10.5.6. I have just installed a version of JBoss that
> relies on Java 1.6, and therefore, requires you to set JAVA_HOME to
> point to the Java 1.6 install directory. However, currently JAVA_HOME
> is pointing to a 1.5 installation, and I would like to keep it that
> way because I have some other apps that rely on Java 1.5. Is there a
> way I can define JAVA_HOME only for scripts run within a certain
> directory (namely, the JBoss installation)?

Variables are defined in the context of the shell process (and possibly
a shell's child processes, if exported), it's not defined in the context
of some base directory "where you start the script". (I put it in quotes
because you should be aware that you can start a script from any directory
with absolute path as well; how should it behave then?)

So there's the possibility to change your wrapper script. The most simple
approach may be to put a file in every "relative root" directory where
the variable assignment is defined and change the script to let it read
that code. Put JAVA_HOME=... in some file, say .java_home, and source
it from your wrapper script using

. ./.java_home

Janis

>
> Thanks for any thoughts, - Dave
From: Stephane CHAZELAS on
2009-11-13, 16:54(+01), Janis Papanagnou:
> laredotornado wrote:
>> Hi,
>>
>> I'm using Mac 10.5.6. I have just installed a version of JBoss that
>> relies on Java 1.6, and therefore, requires you to set JAVA_HOME to
>> point to the Java 1.6 install directory. However, currently JAVA_HOME
>> is pointing to a 1.5 installation, and I would like to keep it that
>> way because I have some other apps that rely on Java 1.5. Is there a
>> way I can define JAVA_HOME only for scripts run within a certain
>> directory (namely, the JBoss installation)?
>
> Variables are defined in the context of the shell process (and possibly
> a shell's child processes, if exported)

Well, all variables are inherited by child processes
(subshells), when exported, they are also passed in the
environment of the commands _executed_ by those child processes
(and if those executed commands are shells themselves, those
environment variables become shell variables again for those
shells).

--
St�phane