1
â caner@vegan  ~  echo   $JAVA_HOME 

â caner@vegan  ~  echo $PATH     
/home/caner/bin:/home/caner/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
â caner@vegan  ~  

this is now empty.

â caner@vegan  ~    export JAVA_HOME=/usr/local/java/jdk1.8.0_171  
â caner@vegan  ~    export PATH="$PATH:$JAVA_HOME/bin"           
â caner@vegan  ~  echo $JAVA_HOME
/usr/local/java/jdk1.8.0_171
â caner@vegan  ~  echo $PATH     
/home/caner/bin:/home/caner/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/java/jdk1.8.0_171/bin
â caner@vegan  ~  

now i set values. BUt after minutes, it keeps getting unset. As first codes show.

Why is that?

it is ubntu 16.04.

I run some ant commands for hybris but i am not sure if it is about it.

CursedChico
  • 39
  • 1
  • 8
  • Does it happen if you don't run any command? Are you sure you are in the same shell process (or child process) when the variables have been "reset"? – danzel Jun 06 '18 at 13:55
  • For example, in same command which i wrote those in the question, it seems setted. BUt when i open a new terminal, now i saw that it is empty. Now i noticed that, when i set javahome, in new terminal i see it is empty. @danzel this did not work https://askubuntu.com/a/175547/539466 – CursedChico Jun 06 '18 at 14:11
  • That is how environment variables work. Which terminal emulator and shell do you use? – danzel Jun 06 '18 at 14:13
  • I am using yakuake with zsh. I noticed also i cant open default terminal. when i try gnome from akuake, it says `â caner@vegan ~ gnome-terminal Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 8 ` i downloaded jdk 8 only and gave its path. – CursedChico Jun 06 '18 at 14:17
  • Then you have to add the `source /etc/environment` line to `~/.zshrc` (because, well, zsh not bash). I've seen a question some days ago regarding the error you described, just search on AskUbuntu. – danzel Jun 06 '18 at 14:21
  • @danzel i added this line `# If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/local/bin:$PATH source /etc/environment ` then again export path and javahome and then `source ~/.zshrc` but it did not work again when i opend new terminal tab :( – CursedChico Jun 06 '18 at 14:25
  • You need to export the environment variables in `/etc/environment` (add the `export PATH=...` lines to that file). Then you add the `source ...` line to `~/.zshrc`. Now if you open a new terminal, the variables should be set. – danzel Jun 06 '18 at 14:31
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/78536/discussion-between-danzel-and-cursedchico). – danzel Jun 06 '18 at 14:38
  • I added to `etc/profile` those `export JAVA_HOME=/usr/local/java/jdk1.8.0_17 export PATH=$JAVA_HOME/bin:$PATH` then source it and zsh but even in that terminal, jvahome is still empty. Before, i added to zshrc this ` source /etc/environment ` then path became this `$ echo $PATH /usr/local/java/jdk1.8.0_17/bin:/usr/local/java/jdk1.8.0_17/bin:/usr/local/java/jdk1.8.0_17/bin:/usr/local/java/jdk1.8.0_17/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/.... `. i did source to zsh,env and profile. After i source enviroment, javahome is being deleted. – CursedChico Jun 06 '18 at 14:44

1 Answers1

0

I did those steps.

I went to

sudo nano /etc/environment

I added those

export JAVA_HOME="/usr/local/java/jdk1.8.0_171"
export ANT_HOME="/usr/local/ant"

export PATH=$ANT_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH

This sets globally.

But for terminal, it has to refresh this , for example when i open a new terminal.

So i also added bottom of my zsh configuration:

sudo nano ~/.zshrc   

this

 source /etc/environment

and now it works.

CursedChico
  • 39
  • 1
  • 8