Introduction
Unresolved compilation problems in the code are due to compilation errors in the code.
Many problems can be detected if we use an IDE like IntelliJ, Eclipse IDE, etc. This is a very generic error and there could be multiple reasons to get this error.
Error
Let’s see a sample error that has a typo in the method name.
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
The method printl(String) is undefined for the type PrintStream
at JavaOutputDemo.main(JavaOutputDemo.java:5)
Fix
As we can see in the Error stack trace, printl(String) is undefined for the type PrintStream.
There is a typo in the method name: printl
The correct method name is println()
i.e System.out.println();
IDE
Using IDE would detect this kind of error and prompt the developer with fixes. In this case, if we hover the mouse would show the correct method names for the class.
Another Example
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
at Sample/com.testingdocs.tutorial.Test.main(Test.java:50)
Fix: The project is configured with modules. An there is a missing entry for the required module module-info.java. Add the required module in the file and save the file.
For example:
module Sample {
requires java.desktop;
}