Avatar billede fredand Forsker
02. december 2020 - 07:11 Der er 4 kommentarer

Where did I set my JAVA_HOME on my Linux?

Hello guys,

I use Linux Mint and need to use my maven with openjdk11, but it seems like it is configured to use jdk8 in some way and I can frankly not figure out how I did it.
Please look at this output:

fredrik@linuxTwo:~$ java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

fredrik@linuxTwo:~$ mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /opt/java/jdk1.8.0_181/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-20-generic", arch: "amd64", family: "unix"

fredrik@linuxTwo:~$ echo $JAVA_HOME
/opt/java/jdk1.8.0_181

fredrik@linuxTwo:~$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

fredrik@linuxTwo:~$ sudo update-alternatives --config java
[sudo] password for fredrik:
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                        Priority  Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java  1111      auto mode
  1            /opt/java/jdk-10.0.2/bin/java                1        manual mode
  2            /opt/java/jdk1.8.0_181/bin/java              1        manual mode
* 3            /usr/lib/jvm/java-11-openjdk-amd64/bin/java  1111      manual mode

Press <enter> to keep the current choice
  • , or type selection number:
  • fredrik@linuxTwo:~$

    Is there any other place that I might have set my system to use jdk8?

    Best regards
    Fredrik
    Avatar billede bvirk Guru
    02. december 2020 - 09:03 #1
    I login scripts for bruger frederik måske - hvis login shell er bash kan den lokale hede ~.bash_profile og i dens fravær afvikles noget /etc/......
    Hvordan det specifikt er på Linux Mint ved jeg ikke.
    Avatar billede arne_v Ekspert
    02. december 2020 - 14:39 #2
    Ja. Det er formentlig login profile som saetter JAVA_HOME.
    Avatar billede fredand Forsker
    02. december 2020 - 15:53 #3
    Hello guys,
    You were right!
    I have set it in my .bashrc
    I guess this setting overrides all others.
    Perhaps I could override it setting it in a terminal, for that terminal-session?
    Best regards
    Fredrik
    Avatar billede arne_v Ekspert
    02. december 2020 - 16:17 #4
    I took a look in mvn script.

    If you want a non-intrusive way of setting it, then you can set it in .mavenrc in your home dir as the mvn script will execute that before it moves on.
    Avatar billede Ny bruger Nybegynder

    Din løsning...

    Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

    Loading billede Opret Preview
    Kategori
    Kurser inden for grundlæggende programmering

    Log ind eller opret profil

    Hov!

    For at kunne deltage på Computerworld Eksperten skal du være logget ind.

    Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

    Du kan også logge ind via nedenstående tjenester