Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/fd4760df2f0f39fc14027f59de9c1b65 to your computer and use it in GitHub Desktop.
Save FrancoStino/fd4760df2f0f39fc14027f59de9c1b65 to your computer and use it in GitHub Desktop.
I ran this command in my project directory to build and package it: mvn clean javadoc:jar package I do have my JAVA_HOME variable set correctly. Evidently: $ which java /usr/bin/java $ sudo ls -...

Setting JAVA_HOME using update-alternatives in Linux

Preview:
export JAVA_HOME=$(update-alternatives --query javadoc | grep Value: | head -n1 | sed 's/Value: //' | sed 's@bin/javadoc$@@')
Associated Context
Type Code Snippet ( .sh )
Associated Tags Java Home Update Alternatives Query Javadoc Grep Value head Command sed Command Framework: None JAVA_HOME update-alternatives javadoc environment variable
📝 Custom Description I ran this command in my project directory to build and package it:

mvn clean javadoc:jar package

I do have my JAVA_HOME variable set correctly.
Evidently:

$ which java
/usr/bin/java
$ sudo ls -...
💡 Smart Description This code snippet updates the Java home directory using a command-line tool. The script takes an argument and executes it with specific parameters, including their value or binary file path as input.
A command to set the JAVA_HOME environment variable using update-alternatives in Linux.
🔎 Suggested Searches How to update alternatives in Jinja2 using grep?
Related Links https://stackoverflow.com/questions/13961615/unable-to-find-javadoc-command-maven
https://www.google.com/search?q=javadoc+command%3A+The+environment+variable+JAVA_HOME+ubuntu&newwindow=1&sca_esv=4771c1dce5b9df5f&ei=_CpCZvXbGvmS9u8P3I-h4AY&ved=0ahUKEwj1yamj8oqGAxV5if0HHdxHCGwQ4dUDCBA&uact=5&oq=javadoc+command%3A+The+environment+variable+JAVA_HOME+ubuntu&gs_lp=Egxnd3Mtd2l6LXNlcnAiOmphdmFkb2MgY29tbWFuZDogVGhlIGVudmlyb25tZW50IHZhcmlhYmxlIEpBVkFfSE9NRSB1YnVudHUyBRAhGKABMgUQIRigAUi3ClC-BFjXCXABeAGQAQCYAbwBoAHHBqoBAzAuNrgBA8gBAPgBAZgCB6AC1AbCAgoQABiwAxjWBBhHwgIGEAAYFhgewgIIEAAYgAQYogSYAwCIBgGQBgiSBwMxLjagB8UV&sclient=gws-wiz-serp
https://www.google.com/search?q=MavenReportException%3A+Error+while+creating+archive%3A+Unable+to+find+javadoc+command%3A+The+environment+variable+JAVA_HOME+is+not+correctly+set.&oq=MavenReportException%3A+Error+while+creating+archive%3A+Unable+to+find+javadoc+command%3A+The+environment+variable+JAVA_HOME+is+not+correctly+set.&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg60gEHNDE0ajBqNKgCALACAQ&sourceid=chrome&ie=UTF-8
https://medium.com/@kankvish/fixing-issue-the-environment-variable-java-home-is-not-correctly-set-b5f0b66a84d0
https://www.digitalocean.com/community/tutorials/an-introduction-to-useful-bash-aliases-and-functions
Related People Davide Ladisa
Sensitive Information No Sensitive Information Detected
Shareable Link https://davideladisa.pieces.cloud/?p=78b546adf1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment