Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JAVA_HOME not picked up as en var

Reply
Thread Tools

JAVA_HOME not picked up as en var

 
 
lbrtchx@hotmail.com
Guest
Posts: n/a
 
      05-04-2007
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

 
Reply With Quote
 
 
 
 
blmblm@myrealbox.com
Guest
Posts: n/a
 
      05-04-2007
In article <. com>,
<> wrote:
> 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


[ 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

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK Miss Michelle. Heigardt Java 8 04-09-2011 07:20 PM
Re: capitalize() NOT the same as var[0].upper _ var[1:] James Mills Python 2 06-10-2010 07:34 AM
Difference between Session["var"] and Session("var") thomson ASP .Net 10 06-20-2005 01:02 PM
Difference between Session["var"] and Session("var") thomson ASP .Net 0 06-20-2005 10:54 AM
Threads.. Session var lost, App var ok Alvin Bruney ASP .Net 1 12-02-2003 01:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57