I\'m new to the world of java and have been following a few online tutorials to get started. Everything was going great and the programs were compiling perfectly and then al
That happens because you haven't installed JDK but only JRE. Install JDK to make it work.
Source
I too have had this problem. Try restarting Eclipse. If that doesn't work, restart your computer. If even that doesn't work, re-install Java. Its an annoying bug that usually occurs when your computer goes into standby while a program is running on Eclipse.
EDIT: If the problem persists, you can make a small javac program that would compile any code in a given directory.
Hope I helped!