ToolProvider.getSystemJavaCompiler () Gets the Java compiler null pointer exception

Let me talk Conclusions: / lib directory under the JRE directory of tools.jar lost, a copy can also be re-Installs JREs, we recommend the latter from the corresponding JDK's / lib file.


 Dynamic learning Java compile time, inevitably get Java compiler. And up and running, there is a null pointer exception.

 

Ctrl-click getSystemJavaCompiler (), it will jump to not find the source interface.

Change Attached Source, you will be surprised to find that you can not find even tools.jar package. As we all know, jre is the Java Runtime Environment, the operating environment in the corresponding jar package did not even nature will be reported null pointer.

The easiest way is to copy a file over from the JDK to run again.

At this point you hold down the Ctrl Click to view the source code, they still can not find the source, although the program can be run up. Typical palliative.

Click Window Eclipse navigation bar -> Java -> Installs JREs, library Remove the old jre off, Add a new, JRE Type select Strandard VM, and then browse the directory, select the JDK folder (where the surface is prompted JRE directory , recommended to choose JDK folder).

 

 Then Finish, return to the interface, the new JRE sit in front of the library on the check, Apply and Close out. So you can see the source code.

Guess you like

Origin www.cnblogs.com/mohou/p/12505410.html