spdx / tools-java

SPDX Command Line Tools using the Spdx-Java-Library
Apache License 2.0
59 stars 34 forks source link

bug: Cannot build tools-java - unable to find javadoc command #129

Closed nishakm closed 8 months ago

nishakm commented 1 year ago

mvn clean install gives me an error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar (attach-javadocs) on project tools-java: MavenReportException: Error while creating archive: Unable to find javadoc command: The javadoc executable '${env.JAVA_HOME}/bin/javadoc' doesn't exist or is not a file. Verify the <javadocExecutable/> parameter. -> [Help 1]

I do have javadoc installed though:

$ which javadoc
/usr/bin/javadoc

My java environment:

$ java -version
openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.19+7-post-Ubuntu-0ubuntu122.04.1, mixed mode, sharing)
goneall commented 1 year ago

@nishakm can you paste the value of the environment variable JAVA_HOME (e.g. printenv JAVA_HOME)?

goneall commented 1 year ago

Actually, looking at the above, it looks like javadoc is in the bin directory - it may not be in the JAVA_HOME directory which is where the Maven plugin is looking for it.

goneall commented 9 months ago

@nishakm - were you able to get this to work? Should we close this issue?

nishakm commented 8 months ago

@goneall I haven't tried since. I'll give it a try after I update my working branch and report back.

nishakm commented 8 months ago

I can't get rid of the error. My JAVA_HOME was not set. I set it to /usr (which I think is what mvn is looking for: '${env.JAVA_HOME}/bin/javadoc') but I get another error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar (attach-javadocs) on project tools-java: MavenReportException: Error while creating archive: 
[ERROR] Exit code: 1 - /home/nisha/tools-java/src/main/java/org/spdx/tools/SpdxConverter.java:31: error: cannot access RdfStore
[ERROR] import org.spdx.spdxRdfStore.RdfStore;
[ERROR]                             ^
[ERROR]   bad class file: /home/nisha/.m2/repository/org/spdx/spdx-rdf-store/1.1.9/spdx-rdf-store-1.1.9.jar(org/spdx/spdxRdfStore/RdfStore.class)
[ERROR]     class file has wrong version 55.0, should be 52.0
[ERROR]     Please remove or make sure it appears in the correct subdirectory of the classpath.
[ERROR] 
[ERROR] Command line was: /usr/bin/javadoc @options @packages
[ERROR] 
[ERROR] Refer to the generated Javadoc files in '/home/nisha/tools-java/target/apidocs' dir.
goneall commented 8 months ago

@nishakm - you did fix the JavaDocs issue :)

You're now onto a different issue :(

What version of Java are you using? The RDFStore feature requires version 11 or above.

You can run java --version to find it.

nishakm commented 8 months ago

@goneall my java version:

$ java --version
openjdk 11.0.21 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
goneall commented 8 months ago

In looking more closely at the error message, it looks like JavaDocs is erroring out which is unusual since it already compiled.

My guess is that you have more than one Java version installed and you may have set JAVA_HOME to a version 8 rather than the default version 11.

Try executing ${env.JAVA_HOME}/bin/java --version and see what you get.

nishakm commented 8 months ago

Looks like my jdk version is 11 but my javac version is still 1.8. Let me see if I can resolve this, but it looks like it's my installation's fault and not a code bug. So I will close this issue.

nishakm commented 8 months ago

I upgraded my javac version (not particularly straightforward to do) and that fixed it!