0

Is it possible to use a generic Folder Name for the JAVA_HOME Environment variable in Linux?

At the Moment our JAVA_HOME variable is set to /usr/lib/Java_1_8_212 and when the server was updated to Java_1_8_222 our application Server stopped working because the old Folder does not even exist.

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64/jre

What is the recommendation here?

  1. Ask our infrastructure Team to always use a generic Folder and set JAVA_HOME=/usr/lib/Java/jre

  2. Ask our infrastructure Team to always update the JAVA_HOME variable with the new Folder name

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Jesus Paradinas
  • 189
  • 2
  • 12

1 Answers1

1

Use a symbolic link for JAVA_HOME which would point to the jdk/jre you want

eg : JAVA_HOME=/path/to/symlink

ls -l /path/to/symlink
/path/to/symlink -> /path/to/your/actual/jdk
nullPointer
  • 4,419
  • 1
  • 15
  • 27
  • Thanks but does not solve the Problem. If the infrastructure Team updates Java and removes the old Java_home Folder then the link will not work – Jesus Paradinas Nov 06 '19 at 10:09
  • 1
    Of course you would need to do at least _something_ if your java directory used gets deleted. How would you expect this to work ? With my suggestion you'd only need to update the symlink, without ever needing to change/update the env variable – nullPointer Nov 06 '19 at 10:11
  • 1
    So, you've moved them having to update the home folder to instead having the update symlink? They are still at the point they would have to update something during an update? It doesn't really solve the problem, but instead moves it slightly – Draken Nov 06 '19 at 10:16
  • yes exactly, what I want to avoid is the Manual step. It would be great if Java could always use a generic folder. I can ask the Infrastructure Team to always use the same Folder but as I am not sure if it is a good practice I wanted to ask the question here before. – Jesus Paradinas Nov 06 '19 at 10:24
  • 1
    @JesusParadinas in my opinion ask infra team to keep older folder as it is and create new folder for updated java version..update the symlink to point to new folder..delete older java version folder after app validation..This is how we're doing from past few years – Sagar Kadu Nov 06 '19 at 11:23