FatalError while creating javadoc (Unable to find package java.lang)

本秂侑毒 提交于 2019-12-19 03:25:15

问题


I'm trying to run javadoc in my java project using Eclipse Kepler under Linux but I'm getting this error:

Constructing Javadoc information...
com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
    at com.sun.tools.javac.comp.MemberEnter.importAll(MemberEnter.java:137)
    at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:521)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:454)
    at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:400)
    at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:831)
    at com.sun.tools.javac.code.Symbol.complete(Symbol.java:400)
    at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:782)
    at com.sun.tools.javac.comp.Enter.complete(Enter.java:481)
    at com.sun.tools.javac.comp.Enter.main(Enter.java:459)
    at com.sun.tools.javadoc.JavadocEnter.main(JavadocEnter.java:71)
    at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:180)
    at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:364)
    at com.sun.tools.javadoc.Start.begin(Start.java:162)
    at com.sun.tools.javadoc.Main.execute(Main.java:59)
    at com.sun.tools.javadoc.Main.main(Main.java:49)
javadoc: error - fatal error
1 error

What am I doing wrong?


回答1:


Try adding rt.jar from JAVA_HOME/lib/ to the bootclasspath. For example :

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9.1</version>
        <configuration>
           <minmemory>256m</minmemory>
           <maxmemory>1024m</maxmemory>
           <!-- error fix -->
           <bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
        </configuration>
        <reportSets>
           <reportSet>
              <reports>
                 <report>aggregate</report>
              </reports>
           </reportSet>
        </reportSets>
     </plugin>



回答2:


@HAL - The path is netbeans path. In eclipse(as you are using eclipse) there is same path. Make sure the jre path is selected properly.

In windows Eclipse the path is (Not sure about Linux)

windows > preferences > Java (Left tree) > Installed JREs

There you will get the jre's eclipse is configured with.

Remove them and add them again then refresh the project and check if this works.



来源:https://stackoverflow.com/questions/20272715/fatalerror-while-creating-javadoc-unable-to-find-package-java-lang

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!