2

I had open JDK installed in my Linux EC2. But then i installed oracle JDK. As i wanted to set oracle JDK path for all users i have set in

  /etc/profile

When i do echo $JAVA_HOME.It shows me correct path of oracle JDK. But when i do it shows me path of openJDK.

 $env
  JAVA_HOME path showing open JDK

Please suggest why JAVA_HOME is still pointing to openJDK and how to make it point to oracle JDK for all users.I have reboot the system but its still showing openJDK path when i do env.

AWS_Lernar
  • 627
  • 2
  • 9
  • 26
  • 1
    I think the issue here is that the OpenJDK version of Java is on your Linux `PATH`. [See here](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix) for some ideas on how to also set your path. – Tim Biegeleisen Feb 02 '20 at 10:40

1 Answers1

0

From https://superuser.com/questions/664169/what-is-the-difference-between-etc-environment-and-etc-profile

/etc/environment - This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings

You may be seeing environment variables for a non interactive shell. Non interactive shells do not invoke /etc/profile.

Try setting the path in /etc/environment instead. This is the correct file to use for setting the system path.

Rodrigo Murillo
  • 13,080
  • 2
  • 29
  • 50