Cannot change default Java version from 11 to 1.8












0















I open new terminal and type java -version and see I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


I want default Java version to be 1.8, so I check that I have Java 1.8 installed which I do because I type /usr/libexec/java_home -V and get



11.0.1, x86_64: "OpenJDK 11.0.1"    /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
1.8.0_192, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home


so I create new profile with vim ~/.profile and set JAVA_HOME and write and save



#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/"


then I close and open terminal and type echo $JAVA_HOME and get correct JAVE_HOME variable



/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/


but then I type java -version and still get that I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


so I type directly into terminal



export JAVA_HOME="/usr/libexec/java_home -v 1.8


and I see that java version is now Java 1.8



java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


but If i open new terminal , my version of Java is back to Java 11, so I add the export statement directly to ~/.profile



#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home -v 1.8


but still the default version of Java when opening a new terminal is Java 11.



So I change profile to



#!/bin/bash
JAVA_HOME="/usr/libexec/java_home -v 1.8"


and open new terminal still java -v gives Java 11.



How do do I change the default version of Java on OSX from Java 11 to Java 1.8?










share|improve this question























  • Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

    – Joachim Sauer
    Nov 20 '18 at 22:13
















0















I open new terminal and type java -version and see I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


I want default Java version to be 1.8, so I check that I have Java 1.8 installed which I do because I type /usr/libexec/java_home -V and get



11.0.1, x86_64: "OpenJDK 11.0.1"    /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
1.8.0_192, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home


so I create new profile with vim ~/.profile and set JAVA_HOME and write and save



#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/"


then I close and open terminal and type echo $JAVA_HOME and get correct JAVE_HOME variable



/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/


but then I type java -version and still get that I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


so I type directly into terminal



export JAVA_HOME="/usr/libexec/java_home -v 1.8


and I see that java version is now Java 1.8



java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


but If i open new terminal , my version of Java is back to Java 11, so I add the export statement directly to ~/.profile



#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home -v 1.8


but still the default version of Java when opening a new terminal is Java 11.



So I change profile to



#!/bin/bash
JAVA_HOME="/usr/libexec/java_home -v 1.8"


and open new terminal still java -v gives Java 11.



How do do I change the default version of Java on OSX from Java 11 to Java 1.8?










share|improve this question























  • Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

    – Joachim Sauer
    Nov 20 '18 at 22:13














0












0








0


2






I open new terminal and type java -version and see I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


I want default Java version to be 1.8, so I check that I have Java 1.8 installed which I do because I type /usr/libexec/java_home -V and get



11.0.1, x86_64: "OpenJDK 11.0.1"    /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
1.8.0_192, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home


so I create new profile with vim ~/.profile and set JAVA_HOME and write and save



#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/"


then I close and open terminal and type echo $JAVA_HOME and get correct JAVE_HOME variable



/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/


but then I type java -version and still get that I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


so I type directly into terminal



export JAVA_HOME="/usr/libexec/java_home -v 1.8


and I see that java version is now Java 1.8



java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


but If i open new terminal , my version of Java is back to Java 11, so I add the export statement directly to ~/.profile



#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home -v 1.8


but still the default version of Java when opening a new terminal is Java 11.



So I change profile to



#!/bin/bash
JAVA_HOME="/usr/libexec/java_home -v 1.8"


and open new terminal still java -v gives Java 11.



How do do I change the default version of Java on OSX from Java 11 to Java 1.8?










share|improve this question














I open new terminal and type java -version and see I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


I want default Java version to be 1.8, so I check that I have Java 1.8 installed which I do because I type /usr/libexec/java_home -V and get



11.0.1, x86_64: "OpenJDK 11.0.1"    /Library/Java/JavaVirtualMachines/openjdk-11.0.1.jdk/Contents/Home
1.8.0_192, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home


so I create new profile with vim ~/.profile and set JAVA_HOME and write and save



#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/"


then I close and open terminal and type echo $JAVA_HOME and get correct JAVE_HOME variable



/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/


but then I type java -version and still get that I have Java 11



java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)


so I type directly into terminal



export JAVA_HOME="/usr/libexec/java_home -v 1.8


and I see that java version is now Java 1.8



java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)


but If i open new terminal , my version of Java is back to Java 11, so I add the export statement directly to ~/.profile



#!/bin/bash
export JAVA_HOME=`/usr/libexec/java_home -v 1.8


but still the default version of Java when opening a new terminal is Java 11.



So I change profile to



#!/bin/bash
JAVA_HOME="/usr/libexec/java_home -v 1.8"


and open new terminal still java -v gives Java 11.



How do do I change the default version of Java on OSX from Java 11 to Java 1.8?







bash macos command-line .profile






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 21:55









the_prolethe_prole

2,82663176




2,82663176













  • Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

    – Joachim Sauer
    Nov 20 '18 at 22:13



















  • Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

    – Joachim Sauer
    Nov 20 '18 at 22:13

















Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

– Joachim Sauer
Nov 20 '18 at 22:13





Neither Java itself nor the shell (that finds which java executable to run) cares about JAVA_HOME. Many shell scripts that start Java based applications will pick that environment variable to decide which JVM to start, but if you simply run java then it will run what's on the PATH.

– Joachim Sauer
Nov 20 '18 at 22:13












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402187%2fcannot-change-default-java-version-from-11-to-1-8%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402187%2fcannot-change-default-java-version-from-11-to-1-8%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy