Need help setting Java 18 as default pleas -- getting desperate and frustrated

Hello. I don't know if this is the right site to post his, but I'l try. Can't see how it can hurt.

It's been a long time since i've been here. So forgive me if I ask basic questions; haven't been on the terminal for a while. My question is regarding setting my downloaded Java18 as the default version.

My computer is an IMac 11,6, quad core iG, 16 GB ram, running el Capitan, bash version 3.2 There were four or five years where I didn't use it because the backlight has gone out, and I just didn't get around to getting an external monitor. But I got one a couple weeks ago, and lo and behold the machine still works great. Same problem with my 2010 MB pro (intel core 2 duo, 8 GB ram). So I'm back on my iMac, and trying to update things, while I as well learn about Linux. Once the apples go out and can' t be used it's Linux from now on.

I've been to other sites to ask this and have gotten somewhat confusing answers, in part at least because for my part I've forgotten some Unix commands -- I'm reading about JAVA_HOME and java_home (not sure of the difference), as well as numerous replies as to where I should put these commands. I've been trying to simply find the right file where they might be, but can't. There are a couple of directories where I've found files that have "Java" in them, but not sure which is the right one.

Anyway.....I downloaded Java18 from the Oracle website, just like earlier versions, and it installs, etc. But when I enter "java -version" it says java 1.8 (java 8, build 112 or something like that), even though the directory for Java18 is in the same directory, /Library/Java/JavaVirtualMachines.

For the life of me I can't figure out what's going on and how to set Java18 as the default version. I want to relearn UNIX with all of this, but for now I just need to set Java18 as the default, and I don't know what to do, and am getting a bit frustrated and desperate. Is there anyone out there who can help me, and maybe explain what commands are needed, and what they mean, etc?

Here are a few things I've learned at the Terminal:

echo "JAVA_HOME" yields a blank line

Here's what is given with the following command
/usr/libexec/java_home -V
Matching Java Virtual Machines (12):
1.8.0_112, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
1.8.0_92, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
1.8.0_77, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home
1.8.0_74, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home
1.8.0_73, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
1.8.0_66, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home
1.8.0_65, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
1.8.0_60, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
1.8.0_51, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
1.8.0_31, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
1.8.0, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
1.7.0_51, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

Notice here that Java 18 isn't listed, (both version 18.0.1.1 and 18.0.2) even though it's in the same directory; I can see it in the finder window.

Has anyone had this problem? Could there be a problem because I'm skipping so many versions from java 8 to java 18? Exactly what does java_home -V mean? I tell ya, sometimes the man pages are not the easiest to understand. I didn't have a problem updating to Java 18 on my MB pro -- but then again, I update to High Sierra. Not sure if I want to do that

I'll leave it here for now. If you need any other information please let me know -- and please help. I'm at a loss

According to the following quick reference, which I did not confirm with a second source, you can upgrade to:

High Sierra
macOS 10.13.x

Hence, I kindly suggest you should do as clean of a High Sierra new install as you can, and if you can build from scratch, even better (full clean install).

Then, after you complete that install, first note the Java version installed on High Sierra and come up with a plan based on the latest version of macOS your machine supports.

Reference:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.