0

I am very new in Ubuntu and I am lost about Environment Variable. I have read some Forums but I didn't understand yet.

If I type java -version I got the java confirmation but if I type echo $JAVA_HOME there is nothing or echo $PATH there is nothing related to java.

In some forum I read to create /etc/profile.d/java.sh file and add the export commands. Other one tells to edit /etc/environment, other tells to add export commands in /etc/profile and even other one tells to edit bash.bashrc.

Currently, there is the java in my Ubuntu in /usr/lib/jvm/java-8-oracle/jre and I am able to run some java tools (eg. Eclipse) but I am trying to add Maven and I am very confused how do the environment variables work in Ubuntu. I came from Windows and basically I would like to set these variables as simple as possible.

Danatela
  • 13,243
  • 11
  • 45
  • 72
DemeCarv
  • 185
  • 1
  • 10
  • One of the document mentioned in this link I have read (https://help.ubuntu.com/community/EnvironmentVariables). But I am still confused. For instance: I added Maven variables in /etc/profile and when I type mvn -v I see with other Maven information "Java home: /usr/lib/jvm/java-8-oracle/jre" but where is this JAVA_HOME settled in? It is strange for me because if I type echo $JAVA_HOME the outcome is blank. Do "apt get install" creates automatically some variables in certain file? If so, where is this file? – DemeCarv Jul 14 '14 at 03:14
  • One more doubt: I didn't find ~/.pam_environment. I found etc/pam.conf. Are they the same? – DemeCarv Jul 14 '14 at 03:16
  • 2
  • Probably JAVA_HOME isn't set. Maven takes it's location from default.java alternative. 2. Not the same. Everything in /etc is system-wide and ~/ is user-wide. I recommend you to place JAVA_HOME inside /etc/environment unless custom user java home is required.
  • – Danatela Jul 14 '14 at 03:23
  • 2
    Actually, most of the questions you have are answered in https://help.ubuntu.com/community/EnvironmentVariables For instance it recommends that you don't edit /etc/profile directly. So /etc/profile.d/java.sh or (as @Danatela suggested) /etc/environment are proper places. – Gunnar Hjalmarsson Jul 14 '14 at 07:41
  • Danatela, sorry for the simple question and not related to the origin question but what does ~/ mean? Does it point for the user home? – DemeCarv Jul 14 '14 at 13:16
  • Gunnar, where is ~/.pam_environment mentioned in the article? – DemeCarv Jul 14 '14 at 13:20
  • here - https://help.ubuntu.com/community/EnvironmentVariables#A.2BAH4ALw.pam_environment – Panther Jul 15 '14 at 19:30