I am new to programming (only started learning yesterday) and have encountered an issue with Eclipse. I have been following the "Java for Complete Beginners" video course at https://courses.caveofprogramming.com/ and am currently on the lecture "Strings: Working With Text." I have completely copied the lines of code present at the 5:00 mark, but instead of outputting "Hello" in the console, it give me the error "Error: Could not find or load main class Application." I have looked everywhere (including here, at stack overflow) and have not been able to find a solution I could either understand or worked. It is to my understanding that it probably has something to do with the .classpath file, but I can't even figure out how to edit it. It is also important to note than up until this lecture, I've been doing all of my coding on the Netbeans IDE 8.2. I am using JDK 1.8.0_192 and JRE 1.8.0_192 if that helps. How can I make this error go away? Screenshot of my eclipse
-
Post your code here, no screenshots. – Sergei Sirik Dec 12 '18 at 02:21
-
Also, describe exactly how you execute it in eclipse. I see on your screenshot that you are trying to execute it with `javaw` which is not correct. It has to be executed with simply `java`. – Sergei Sirik Dec 12 '18 at 02:25
-
I executed it by pressing the green run button at the toolbar. In the future, I'll post code. How do I change it from `javaw` to `java`? – Wally Holbeck Dec 12 '18 at 02:33
-
Have you seen [this](https://stackoverflow.com/questions/11235827/eclipse-error-could-not-find-or-load-main-class)? – 萝莉w Dec 12 '18 at 02:40
-
I have seen that post. I can't seem to edit my .classpath file, however – Wally Holbeck Dec 12 '18 at 02:43
-
Most likely just me not knowing how to, however. When I try to open it, there aren't any applications to open it with – Wally Holbeck Dec 12 '18 at 02:44
-
I just searched for this, it seems that something wrong with the file `.metadata`, try to remove it, then restart Eclipse and rebuild it. – 萝莉w Dec 12 '18 at 03:06
-
@萝莉w I deleted the folder `.metadata` in my `eclipse-workspace` folder. After starting Eclipse again, it made the folder again on its own. It still brings up the same error. Thanks you for the response, though. – Wally Holbeck Dec 12 '18 at 03:11
2 Answers
I understand that this isn't really an answer to the problem, so I'm sorry to anyone who might find this post looking for a solution,though I would recommend trying everything the lovely people who chose to respond have suggested. I opted to just completely uninstall Eclipse, Java JDK and Java JRE, and after reinstalling everything and trying the code again, it worked. I assume the issue stemmed from the fact that my JDK and JRE were previously being used and set up for Netbeans, but I'm sorry that I can't offer further information. Thank you to everyone who responded.

- 21
- 1
I think it is exactly as it said. You didn't run a correct program so it could not find the main class.
And maybe You can just set your package there, On the Src, Right Click and add new package and named it. on the package itself add the java class, there your code will work.
From what I seen in your screenshot, you run the javaw.exe. You can try this instead:
Right Click on your Application.Java, Then Choose Run As, Then Choose Java Application.
consider this, I hope this give you a solution for your problem.

- 164
- 11
-
Thank you for the reply. I created a new package named 'test', right clicked and clicked on 'New > Class.' After retyping the code, it still didn't work, this time with the message `Error: Could not find or load main class test.Application.`I also tried 'Run As' and clicking 'Java Application,' to be greeted with the same error message. – Wally Holbeck Dec 12 '18 at 03:02
-
Did you create a new project or just moved it manually? I think you must delete your run configuration first. and have you consider to clean and build the project? – Serafin William Dec 12 '18 at 03:40