1

I have a linux mint 19x and if I do:

echo $JAVA_HOME >> /usr/lib/jvm/java-8-oracle

I want to change the path to put Java 11, but not in the .bashrc, .profile, /etc/enviroment file, I see my JAVA_HOME defined

I tried to put the JAVA_HOME path in my /etc/environment

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Can someone tell me where my JAVA_HOME can be defined, so I can change it well.

Jose
  • 1,779
  • 4
  • 26
  • 50
  • tried export JAVA_HOME=YOURPATH ? – pikkuez Jan 20 '20 at 13:47
  • _Off-Topic_: This may be of your interest (since it handles this change of what java you're using in a given time from shell): [SDKMAN](https://sdkman.io/) and [How to install JDK under Ubuntu?](https://stackoverflow.com/a/53083341/5640649) – lealceldeiro Jan 20 '20 at 13:50

3 Answers3

2

Via the command line, you can simply change your JAVA_HOME variable path:

export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Then redefine the current path prefixing the jdk binaries:

export PATH=$JAVA_HOME/bin:$PATH

NB: This will only take effect within the current terminal session.

tmarwen
  • 15,750
  • 5
  • 43
  • 62
0

Another great option is to use SDKMan to manage SDKs like Java and so on.

I use all the time on all my Linux machines and it's very easy to switch between Java version.

You can find the link here:

https://sdkman.io

leopal
  • 4,711
  • 1
  • 25
  • 35
akortex
  • 5,067
  • 2
  • 25
  • 57
0

Firstly, check what JDKs you have installed :

sudo update-alternatives --config java
   # And select the usr/lib/jvm/java-11-openjdk-amd64/bin/java version.
   # Also, set the JAVA_HOME variable for Maven to pick the correct JDK:

Then :

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Andrei Tigau
  • 2,010
  • 1
  • 6
  • 17