• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

trouble updating JDK 17 in Elementary OS -- can anyone help?

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this is the right place -- or even site -- to post this, but here goes:

I've dabbled with Linux in the past, but my MB pro is dying sadly -- started yesterday, in fact (something with the backlight; it sort of slight dims periodically, and at the bottom of the display, it looks like a series of spotlights shining upward, if that makes sense) -- and it's time to switch. I have experience with the command line in the Terminal app, so most of the commands -- at least the basic ones -- I'm familiar with in Linux.  I'm getting tired of apple anyway -- not what it used to be.

I 'm running elementary OS, and was able to download and install the Open JDK for Java 17. I'm working on a project as a way of learning Java. I have a folder labeled "Contacts Java Classes", and I know how to get to the folder, etc. There's a file that I want to run which contains the main method to get things going -- 'MainWIndow.java'

I can compile the file. Before when I tried to run the file w/o compiling I got this error:

Error: LinkageError occurred while loading main class MainWindow
java.lang.UnsupportedClassVersionError: MainWindow has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 61.0
After compiling the file, and trying to run it I get this:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-17-openjdk-amd64/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:315)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:285)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1392)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1390)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1389)
at java.desktop/java.awt.Toolkit.initStatic(Toolkit.java:1427)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1401)
at java.desktop/java.awt.Component.<clinit>(Component.java:624)
at MainWindow.<init>(MainWindow.java:10)
at MainWindow.main(MainWindow.java:52)


Everything works fine on my MB Pro. But even thought I've dabbled before in Linux -- and I just mean dabble, since I always had my OS X -- I'm not sure what's going on.

Should I upgrade to Java 18? And if so, what's the best way to do it? Can anyone help me out? I'v been on other forums, but I'm not sure what I need to ask, and I think I may have gotten under some people's skin. The installing on OS X is easy, but it's more complicated here in Linux, and I'm not sure where to go.

I currently have the open JDK version, but there are versions on Oracle's site (Are they the same thing?). I tried downloading and installing them once last December, but I wasn't sure how to proceed, which versions I needed, and it was somewhat confusing trying to find the answers on the web.

Please offer me any assistance if you can. I wish to stress that my knowledge of Linux is very slight at this point, and I just want to get Java going on it, while I learn more about Linux. Does that make sense?
 
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error explains: "java.lang.UnsupportedClassVersionError: MainWindow has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 61.0 "

You compiled the app using Java 18, but you are running it using Java 17.
 
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
Well, that's obvious .

So, can you direct me to any sources that can instruct me how to upgrade to Java 18?
 
Salil Wadnerkar
Ranch Hand
Posts: 185
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this out: https://www.linuxcapable.com/how-to-install-openjdk-18-on-ubuntu-22-04-lts/
 
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
Thank you, Salil.  I should have guessed that, since I got my 17 version instructions from there.  But I was so stressed out about this that I didn't even think to search for it.  My bad.

I do have a question out of curiosity.  The page says that Open JDK is free, and the versions downloaded from Oracle are licensed, but on OS X there was no need to get a license or anything like that.  I just downloaded it, no problem.   What gives?  Is there a big difference between the open version and the version on the oracle website?  There are Linux versions of it on oralce's site, a

would it be better to download the oracle version?  I tried it once, but just couldn't get it to install properly.  

Like I said, just curious, but if it's better to have the oracle version, then I'd rather have that one.
 
Salil Wadnerkar
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you installed oracle jdk using package managers like brew, they accept the license on your behalf. Their post-install message says so. If you installed oracle JDK by downloading .dmg file, the installer program asks you to accept the license, I think.
Oracle and OpenJDK don't have any practical difference. You can use any one of them.
 
Sheriff
Posts: 4639
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christopher Laurenzano wrote:The page says that Open JDK is free, and the versions downloaded from Oracle are license


There were licensing changes with JDK 17 - refer to the Oracle Java SE Licensing FAQ for the details.

Oracle Java SE Licensing FAQ wrote:Oracle JDK 17 and later is available under the Oracle No-Fee Terms and Conditions License which permits free use for all users.

 
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
Well wouldn't you know it -- the repository it mentions doesn't have open JDK 18 in it.   There is another method to download the latest JDK build, but i don't know whether my machine has the Linux AARCH 64 or the x64.  I'm unfamiliar with what they are, but I'm guessing some kind of chip architecture, yes?  How can I find out which one I have?  I'm using a dell Latitude E6510 with an intel dual core i7 processor, if that matters.

Do you know of any other repositories that might have JDK 18?

The machine was given to me and was originally running Windows on it, and I installed Linux later.  
 
Ron McLeod
Sheriff
Posts: 4639
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here: Java SE Development Kit 18.0.1.1 downloads ?

x64 RPM Package
 
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
Okay, so can you tell me the difference (was looking at the page you linked) between the debian package an the RPM?  I did some looking around and a Ubuntu site said it's not possible to interchange the two.   It says I need to use the debian package, if I read it correctly.

my apologies for so many posts here.
 
Ron McLeod
Sheriff
Posts: 4639
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RedHat based distributions use the rpm package manager, where Debian based distributions use the apt package manager.

You mentioned Arch Linux (AARCH 64), so I assumed you needed the RPM package.  However, from the thread title it seems like you are using Elementary OS, which (I believe) is Debian-based, so I guess you will need the Debian (apt) package.
 
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
OK, some more help if anyone can give it -- i think I downloaded it properly -- I had to use the tar download.  It's in my /opt folder, /opt/java-18.0.1.1.  But when  type java -version it says that version 17 is the current version.  It's in the /usr/bin/lib directory.   I'd like to make version 18 the default version, but not sure how to do it, because if I type the --config java command it says that 17 is the only version, and there's nothing to configure.


 
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
Um...I have another problem here.

I'm using the code app in elementary os, and decided to write some test programs, rather than use the program that was written in Java 18.

here's the code for my hello program:

This complies and runs fine.

BUT....

For this brief TestWindow program to display a GUI:



I get the same error messages as before:

xception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-17-openjdk-amd64/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:315)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:285)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1392)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1390)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1389)
at java.desktop/java.awt.Toolkit.initStatic(Toolkit.java:1427)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1401)
at java.desktop/java.awt.Component.<clinit>(Component.java:624)
at TestWindow.buildWindow(TestWindow.java:8)
at TestWindow.main(TestWindow.java:16)

Something else is going on here, but I don't know what.  I'm kind of tired and may be missing something, but if not, does anyone have any ideas?  I wrote this program on a machine that's running Java 17 open jdk, and this is the result.   So maybe it's not the version that's the problem.  It has something to do with the "Unsatisfied Link Error."  Don't know what that is and/or how to fix it.  I followed all the instructions to install  open JDK 17 from linuxCapable.  So I'm not sure what's missing.

Please help if you can.
 
Ron McLeod
Sheriff
Posts: 4639
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christopher Laurenzano wrote:OK, some more help if anyone can give it -- i think I downloaded it properly -- I had to use the tar download.  It's in my /opt folder, /opt/java-18.0.1.1.  But when  type java -version it says that version 17 is the current version.  It's in the /usr/bin/lib directory.   I'd like to make version 18 the default version, but not sure how to do it, because if I type the --config java command it says that 17 is the only version, and there's nothing to configure.


You probably didn't need to install a tarball.  If you downloaded the Debian package from the Oracle site, you could have installed it with: sudo apt install jdk-18_linux-x64_bin.deb
That would have installed in the /usr/lib/jvm/jdk-18 directory.

If you want to make the java version which was unpacked at /opt/java-18.0.1.1 then you could create an entry in the /etc/profiles.d directory with something like this:To have this take effect, you can either log-out and and log-in again, or source the file that you would have just created with: source /etc/profile.d/jdk18.sh
 
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
So can you tell me how to Uninstall the version of Java 18 that I have on my machine so I can start over again? I just mean the commander command at the command line that will do this? And do I need to be in the directory where the file is in order to do it?
 
Saloon Keeper
Posts: 28316
207
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
Java is not Internet Explorer. It's not a case of There Can Be Only 1. You can install multiple JDK's and JRE's on any OS, and very definitely on Linux.

In its core form, Java comes as a ZIP (or tar) archive and you can unzip it anywhere and immediately use it. And because it's "anywhere", again, that allows multiple Java installations at the same time. Just reference the desired JVM when you want to run a Java compile or application.

In Red Hat-style systems, in fact, the Oracle JVM's all install as directories under /usr/java and they even softlink /usr/java/latest to point to the most recent release.

However, this self-contained approach is foreign to the Linux LSB file organization where executables for all apps are typically in "bin" directories in the user's PATH, configuration goes under /etc, and so forth. So it's common for native installers (such as the one for OpenJDK) to fudge things to make them run like they're standard Linux.

To avoid conflicts, there is the "alternatives" subsystem for Linux that allows you to select a particular installation for your standard Java needs.

In truth, I find alternatives annoying, so I usually brute-force the more traditional method: setting a JAVA_HOME to point to my preferred JDK or JRE and adding $JAVA_HOME/bin to my PATH.
 
You got style baby! More than this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic