Cannot open Java things, even though I have java installed

I am on a laptop with an Apple M1 Chip if that's important. I'm on OS version Sonoma 14.2.1 as well, but updating my OS hasn't helped in the past.


This has been a problem that has plagued me for literal months. I haven't been able to run ANY Java apps except Minecraft since about September 2023, I think? However, I've installed Java multiple times since Java quit working. Please also note that I cannot code in Java, and these aren't my apps!


I have 2 applications/files I use sometimes that require Java. What they are isn't important here, I think, but since one of them is an actual application and the other is a .jar file I have to open through Terminal, they give me different answers.


For the application, whenever I try and open it, it pops this up:When I click "OK" it just closes.


For the .jar file, after opening a terminal to the folder it's in and trying to run it with

java -jar FileName.jar

It shows this:

Error: Could not find or load main class com.filename.main.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Filename isn't the actual name of the file but I don't think it's important here. I don't know what any of this means. I literally have Java installed on my system, but these apps can't locate the JRE. I don't know what happened. Please help


I should also note/restate that I haven't tried anything besides just reinstalling Java, because I do not know ANY java.

MacBook Air 13″

Posted on Apr 6, 2024 2:55 PM

Reply
10 replies

Apr 7, 2024 8:43 AM in response to ChibiLink

I did. It didn't work. Do I have to uninstall 21 or something

Yes, if you want it to be simple.

I should also note/restate that I haven't tried anything besides just reinstalling Java, because I do not know ANY java.

Well, that's a problem. You must know a lot about Java to make it work. Apple has divorced itself from any support of Java, and Oracle hasn't really stepped up to make it simple.

Modern java "applications" should bundle the JRE within the app package so you don't have to do all of this.

If what you are trying to run is just a .jar file, then you will have to learn quite a bit about Java to make it work.


The linked installer is for a web app plug-in. While not necessarily the way to do it, you can run Java from there, but you need to use the full path to the java app in that plug-in. Are you just trying to run a .jar or do you intend to learn Java? There are different installations for both.


With just the Web Plug-In JRE installed, java will find the only version being 1.8 (or, Java 8).

If you need multiple versions installed, you can either change directory to that home folder or use java_home to find the path:

"`/usr/libexec/java_home -v 1.8`"/bin/java -jar jarfile.jar

Apr 7, 2024 9:28 AM in response to ChibiLink

i just want to run a singlular .jar file i dont plan on having to learn java for anything since i dont see myself going into coding as a job.

Well, you don't have to learn the language, but you do have to learn how to configure it. Or, use java apps from developer's who know what they are doing.

also i cant find how to uninstall java 21

I don't know about the Java 21 installer, but the Java 8 Installer has a Remove option.

If you have a java 21 folder in /Library/Java/JavaVirtualMachines/, just delete that folder.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot open Java things, even though I have java installed

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.