Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

JAVA_HOME not picked up as en var

Thread view: 
lbrtchx@hotmail.com - 04 May 2007 21:53 GMT
Why wouldn't this work?
~
#!/bin/bash

MNT=/mnt/sdb5
JAVA_HOME=${MNT}/JApps/jdk/jdk1.6.0_01
export JAVA_HOME
echo $JAVA_HOME

PATH=${JAVA_HOME}/bin:$PATH
export PATH
echo $PATH

TOMCAT_HOME=/mnt/sdb5/JApps/tc/apache-tomcat-6.0.10
export TOMCAT_HOME
echo $TOMCAT_HOME
~
root@0[kd]# ls -l *.sh
-rwxr-xr-x  1 root root 241 May  4 16:51 javakpath00.sh
~
root@0[kd]# which bash
/bin/bash
~
root@0[kd]# bash -version
GNU bash, version 3.00.16(1)-release (i386-pc-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
~
lbrtchx
blmblm@myrealbox.com - 04 May 2007 23:50 GMT
>  Why wouldn't this work?
> ~
[quoted text clipped - 4 lines]
> export JAVA_HOME
> echo $JAVA_HOME

[ snip ]

Executing a script in the normal way (./thescript, for example)
creates a subshell, and any environment variables you set are
set for the subshell -- and not passed back to the parent shell.
Hence your script has no effect on its caller's environment
variables.

To get the effect I think you want, you need to instead "source"
the script.  If you're also using bash as your interactive
shell, you'd say

 source ./thescript

or

 . ./thescript

Signature

B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.