Fix error “Fatal error compiling: tools.jar not found” of Apache Maven on Eclipse

When working with Apache Maven in Eclipse, I am convinced that no one didn’t encountered an error as below when building the application:

What is the cause?

This is because by default Apache Maven will use the Maven Compiler Plugin plugin to compile the code, which will use the JDK tools.jar library, but the default JRE in Eclipse will not contain this library.

So what is the solution to fix this error?

I would like to guide you as follows:

On the Eclipse menu, go to Window -> Preferences.

Select Java and select Installed JREs:

Fix error "Fatal error compiling: tools.jar not found"

This window displays the default Eclipse JRE,

At this point, you select the default JRE on the right, then click the Edit button, the following window will appear:

Fix error "Fatal error compiling: tools.jar not found"

In this window, you click the Add External JARs … button to add the JDK tools.jar library.

This library is located in the following directory (on Linux or macOS should be different):

Fix error "Fatal error compiling: tools.jar not found"

Select the tools.jar file and press the Open button!

Fix error "Fatal error compiling: tools.jar not found"

Hit the Finish button to close this window!

Fix error "Fatal error compiling: tools.jar not found"

Click OK to close the Preferences window.

OK, let’s try to build your application again. There will be no more errors!

Chia sẽ bài viết này ...Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

2 thoughts on “Fix error “Fatal error compiling: tools.jar not found” of Apache Maven on Eclipse

Add Comment