• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Trying to install Java 17 in Elementary OS (Linux) -- confused. Need some help/advice

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, guys -- I'm trying to get into Linux, and have Elementary OS Odin.  I tried installing Java 17SE.  Came across some web pages, and am confused at this point.

I seemed to have downloaded and installed, if I read these instructions correctly, from the Oracle website.   But when i enter 'java -version' in the terminal it says I have version 1.11 (or java 11).  

I entered update-java-alternatives --list, expecting to see two versions of Java, and I could choose 17 and remove/delete/uninstall 11.  But version 11 was the only one that's there.

Not sure why that is, because when I removed it with the parameter jdk-17, it removed fine.  

Yet, when I enter java -version again, it still says I have version 11.  But when I try to remove that with the dpkg -r command, it says it isn't installed.  But if I enter the command 'update-java-alternatives --list' it lists the jvm and its subdirectories in the usr/bin directory.

Has anyone else encountered this problem?  I have to admit it's confusing installing programs/apps and such in Linux.  

Please let me know if you need any more information.   I've done something wrong somewhere.  

How can I remove the version I seem to still have there, and just start over with a clean installation?  Has anyone been to the oracle website and done this installation?  Seems to me to be a bit confusing/unclear/incomplete for Linux.

I've on other sites/forums as well, but I thought I'd ask here since this is specifically for Java.
 
Marshal
Posts: 76085
362
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you install Java®? Did you use an installation utility (dnf, apt, deb, dpkg, etc.), or did you simply unzip an XXX.tar.gz file? If that latter, how did you add the installation directory to your PATH?
 
Christopher Laurenzano
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Campbell Ritchie:

Not sure at this point :-).  I tried different ways after reading different pages.   Here's what I can tell you:  The current version of Java that's on my computer (if it is even on there) is in /usr/lib/jvm/java 1-11.0-openjdk-amd64.

I'm used to using the terminal on MacOS.  I have at least a sense of what to do and what commands do what in EOS, but now I'm learning that it's not exact, even if it looks the same.  I have some previous experience with Linux, but that was a couple of years ago, and never really got into it.   I want to do that now.

can I get rid of the above file, and if so, what command will do it?  The rm command, yes?  but I'm afraid to do anything at this point for fear of messing up the system, etc.  But if possible I'd like to remove that whole java directory and start over.  Or is there an uninstall command that I have to use?

The oracle page to me wasn't terribly helpful.  I had to go to other pages that I found.  

Maybe I should go to another version of Linux :-)?  Maybe Ubuntu?  
 
Campbell Ritchie
Marshal
Posts: 76085
362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You haven't told us how you tried to install Java®, nor whether you have any idea where it went. Maybe you did install it correctly and simply need to update your PATH.

Christopher Laurenzano wrote:. . . I have at least a sense of what to do and what commands do what in EOS

That sounds like a case of, “A little learning is a dangerous thing.” When running computers, you need to know exactly what to do, and remember it can be different on a different platform.

. . . can I get rid of the above file . . . The rm command, yes?

No, don't remove that directory. Ignore it. Unless you are running out of memory for the / partition, it will do no good, and might instead do a lot of harm.

. . . another version of Linux :-)?  Maybe Ubuntu?  

That is easy enough to do, particularly if your /home directory is on its own partition, but you should still take a complete backup first. But that won't will solve your current problem.
If you are on OpenJDK anyway, why would you need an Oracle product? This link directs you to OpenJDK anyway. Download the file, and put it in a safe location, e.g. ~/Downloads. Then create a directory somewhere. Navigate thither, and unzip the file with tar -zxvf ~/Downloads/OpenJDKXXX.tar.gz or similar. Some of the arguments after the - are redundant.
You will need to update your PATH. See our FAQ. Briefly, add a line similar to the following at the end of the .bashrc file in your home directory, so it matches the installation location. (Beware: .bashrc is a hidden file.)You may need add JAVA_HOME, as in the FAQ if you use an IDE. Note there are several slightly different versions of how to install things.
 
Saloon Keeper
Posts: 25827
184
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note to Campbell: I install the Oracle JDK even though OpenJDK is now a standard pre-install on the Linux flavours I use. It's a holdover from Iced-Tea, which wasn't fully JEE-capable and I'm a coward.

The Linux Alternatives system is an absolute royal pain in the   . It's supposed to allow you to determine which of a set of alternative complex products a given user wants to use, while not excluding other users from different preferences. I've never been comfortable with it and mostly just use brute force.

Java is an odd bird, because OpenJDK installs itself in the standard Linux file locations, which are splattered all over the filesystem, unlike the Oracle/Sun distro which resides in a single directory subtree. It is actually possible to set a JAVA_HOME despite that - I recently did so (shudder). Since the Oracle JDKs download in archive format, you can always set JAVA_HOME to point to the exploded archive and add $JAVA_HOME/bin to your $PATH.

Worth noting is that the best Oracle/Sun Java integration is the RPM (Red Hat/CentOS/Fedora) package. They have a standard where all JDKs/JREs go under /usr/java and set softlinks for /usr/java/latest and a few other convenient abstractions. You can, of course, create your own /usr/java under the Debian-like distros and I usually do. You just have to do it manually.

Alternatives is a mess, but there's also the issue that Linux distros that are out of the mainstream may not be completely friendly to the Oracle packages. That's a completely different problem, though.
 
Greenhorn
Posts: 29
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christopher Laurenzano wrote:Ok, guys -- I'm trying to get into Linux, and have Elementary OS Odin.  I tried installing Java 17SE.  Came across some web pages, and am confused at this point.

I seemed to have downloaded and installed, if I read these instructions correctly, from the Oracle website.   But when i enter 'java -version' in the terminal it says I have version 1.11 (or java 11).  

I entered update-java-alternatives --list, expecting to see two versions of Java, and I could choose 17 and remove/delete/uninstall 11.  But version 11 was the only one that's there.

Not sure why that is, because when I removed it with the parameter jdk-17, it removed fine.  

Yet, when I enter java -version again, it still says I have version 11.  But when I try to remove that with the dpkg -r command, it says it isn't installed.  But if I enter the command 'update-java-alternatives --list' it lists the jvm and its subdirectories in the usr/bin directory.

Has anyone else encountered this problem?  I have to admit it's confusing installing programs/apps and such in Linux.  

Please let me know if you need any more information.   I've done something wrong somewhere.  

How can I remove the version I seem to still have there, and just start over with a clean installation?  Has anyone been to the oracle website and done this installation?  Seems to me to be a bit confusing/unclear/incomplete for Linux.

I've on other sites/forums as well, but I thought I'd ask here since this is specifically for Java.



Others have provided some good suggestions and relevant questions to help narrow down where you are getting stuck.

Though in your case you will still need to use alternatives to display the existing JSE installations. Until JDK17 is available in the repositories for your distribution (Elementary OS Odin) you'll only see JSE11 on offer. Until then if you want it now you'll need to install the rpm from Oracle or, download and install from AdoptOpenJDK. The two JSE are essentially the same.



If the Oracle JDK isn't in that list then you'll need to use alternatives to it manually using the install command. This is a bit fiddly. See the man pages for more help and do some searches for more examples.


Alternatively, if you are looking for something that takes all the pain away take a look at a convenience tool call SDKMan. It is pretty slick. I've been using it for a couple of years now.
https://sdkman.io/

Making life easier. No more trawling download pages, extracting archives, messing with _HOME and PATH environment variables.


Best thing since sliced bread.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like its in the Ubuntu PPA's

https://www.linuxuprising.com/2021/09/how-to-install-oracle-java-17-lts-on.html

Elementary is based on Ubuntu so you should be able to use this guide.

Side note: I wasn't very impressed with Elementary. The app store was atrocious when I checked it out. Which is fine, I don't even use one but new users usually need it until they get comfortable using the myriad ways of installing software on Linux.

Might I suggest Linux Mint or Pop!_OS.

Both of these distros are based off of Ubuntu and the backend should be nearly identical to elementary.    
 
Sheriff
Posts: 8324
594
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

M Bradley wrote:Elementary is based on Ubuntu


So many Linux distros these days that I lost the track.

When I was in the secondary school, there were Slackware and Mandrake among those really popular.

Anyway.

@OP
Did you solve an issue?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic