Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@

# Ignore Mac DS_Store files
.DS_Store
/.idea/
/.oca/
9 changes: 8 additions & 1 deletion visualvm/launcher/visualvm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -61,6 +61,13 @@ case "`uname`" in
;;
esac

# Check if JDK_HOME is set and valid
if [ -n "${JDK_HOME}" ] && [ -d "${JDK_HOME}" ] && [ -f "${JDK_HOME}/bin/java" ]; then
visualvm_jdkhome="${JDK_HOME}"
# Check if JAVA_HOME is set and valid
elif [ -n "${JAVA_HOME}" ] && [ -d "${JAVA_HOME}" ] && [ -f "${JAVA_HOME}/bin/java" ]; then
visualvm_jdkhome="${JAVA_HOME}"
fi

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

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.

Copy link
Member Author

@dasarathirout dasarathirout Aug 4, 2025

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

Copy link

@stoty stoty Aug 4, 2025

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"

Expand Down