Problem: Eclipse is not recognizing my Java code on my Mac (e.g., the main method, String, Object class... none of that is recognized; the pre-built Java classes aren't even there!).
Detail: I have the latest Eclipse (2022-09) and even tried 2022-06. I also have the latest Java version (terminal: "java -version" brings 17.0.4.1). In Eclipse settings, I see the following (see PINK for how I got to these settings, see YELLOW for problem):
But I have the following in Finder:
So maybe the JavaSE/SDK file did not get imported auotmatically. So then I manually try to do that (see PINK), but when I select any of the JavaSE/JDK files from Finder, this happens (YELLOW):
Is there any resolution? Thanks!
Note: Java 17 and Eclipse are both mandatory for my college class. In fact, for the current project, only Java 17 is compatible with the .jars file we need to work with, so there's no other choice.
The correct path for Java on macOS is the Contents/Home
folder in the xxx.jdk
So in the "Installed JREs" you should have something like:
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home
or
/Library/Java/JavaVirtualMachines/jdk-18.0.2.jdk/Contents/Home
As mentioned in the comments running the command
/usr/libexec/java_home -V
will list the available Java installs and the correct paths.