Skip to content

oracle-visualvm-issues-623 Added JAVA_HOME to visulavm luncher & conf - #643

Closed
dasarathirout wants to merge 9 commits into
oracle:masterfrom
dasarathirout:master
Closed

dasarathirout wants to merge 9 commits into
oracle:masterfrom
dasarathirout:master

Conversation

@dasarathirout

@dasarathirout dasarathirout commented Jul 29, 2025 •

Copy link
Copy Markdown
Member

oracle-visualvm-issues-#623 Added JAVA_HOME to visulavm luncher & conf

  • use JAVA_HOME env var
S2-Use-JavaHome-Env
  • Override with --jdkhome argument
S1-Override-JavaHome

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 29, 2025
Comment thread visualvm/launcher/visualvm Outdated

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then
visualvm_jdkhome="$basedir"
if [[ -d "$JAVA_HOME" && -f "$JAVA_HOME/bin/java" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows version also takes JDK_HOME into consideration, maybe it would be better to have the same behaviour.

Comment thread visualvm/launcher/visualvm Outdated
fi

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then
visualvm_jdkhome="$basedir"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this overwrite the visualvm_jdkhome if the config file is present, even if visualvm_jdkhome is not defined in it ?

We only want to override JAVA_HOME if visualvm.conf is found AND visualvm_jdkhome is defined in it.

@dasarathirout dasarathirout Aug 4, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate any insights or corrections you might have.

Won't this overwrite the visualvm_jdkhome if the config file is present, even if visualvm_jdkhome is not defined in it ?

Setting default value for luncher visualvm_jdkhome based on JDK_HOME or JAVA_HOME env.
after we check for visualvm_jdkhome in visualvm.conf (it might not be defined here ) and overide with privious JDK_HOME or JAVA_HOME env any.

We only want to override JAVA_HOME if visualvm.conf is found AND visualvm_jdkhome is defined in it.
My understanding bellow order

  1. we default to env var
  2. then visualvm.conf configuration (if defined , else env )
  3. --jdkhome argument override env & conf

Env set with conf
SS-default

Has env set & conf but ovrride with args
SS-with-args

Only env set , no conf disabled
SS-no-conf

@stoty stoty Aug 4, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your second example covers the case when the config file is in etc/
But line 66/73 overwrites the variable you set in the patch if the config file is found in lib/

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then visualvm_jdkhome="$basedir"

@stoty stoty left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM.

Note that I haven't tested this, only eyeballed.

Comment thread visualvm/launcher/visualvm Outdated
fi
}

set_jdk_java_home_from_conf(){

@stoty stoty Aug 6, 2025 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: set_jdk_java_home would be a better name, as this falls back to environment variables.

@dasarathirout dasarathirout closed this by deleting the head repository Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants