| Author |
setting Linux Java environment
|
Manuel Comnenus
Ranch Hand
Joined: Apr 26, 2006
Posts: 86
|
|
Can someone help me with what is probably a ridiculously simple Fedora Linux environment init problem. I admit that I am a Linux novice - I have always used Windows, but now need to quickly do some things with Java under Linux. I have created a shell script and it works properly when I execute it from a Fedora Linux terminal window. I know that this is the case because I placed echo statements in the script and the echoed statements show that the enviroment variables (path, etc) have changed. However, once the script ends and I type echo $PATH in the terminal session window, the environment is the same as before I executed the script. The script is as follows: #1/bin/sh CLASSPATH="" echo $CLASSPATH export JAVA_HOME=/usr/java/jdk1.5.0_07 echo $JAVA_HOME PATH=$JAVA_HOME/bin:$PATH echo $PATH
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
|
If you execute it by typing its filename, it runs in its own copy of bash. That copy gets the new environment variables; then it exits, leaving the original shell's environment untouched. Instead of executing it, you want the current shell to simply evaluate its contents; you can do that with the dot (.) command: type ". filename", and the code in the file is executed by the current shell.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Manuel Comnenus
Ranch Hand
Joined: Apr 26, 2006
Posts: 86
|
|
Hi Ernest, Could you provide an example? I am a little confused. This is what I am doing in the terminal window. The script is in the current directory and it is named jinit, so I invoke it as with ... ./jinit When I do this, I get the results that I reported. I tried typing .jinit first. This doesn't work, so I am probably misinterpreting your instructions. Thanks.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
There's a space between the dot and "jinit": . jinit
|
 |
Manuel Comnenus
Ranch Hand
Joined: Apr 26, 2006
Posts: 86
|
|
Hi Ernest, Thanks for your help. You were right; a space was required before the file name.
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14486
|
|
|
The dot is a shorthand for a command named "source". It's known as "sourcing" a script.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
To do yourself a favor, it might be a good idea to set it in your permanent environment or in the system environment. There are multiple ways to do it. If you want to set the environment for every user of that machine, in former times you would have set the environment in /etc/profile . I'm using ubuntu-linux where it is done in /etc/environment . For a single user (yourself) you may set in ~/.bashrc and ~/.bash_login if your shell is bash.
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
 |
|
|
subject: setting Linux Java environment
|
|
|