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/
22 changes: 20 additions & 2 deletions 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,9 +61,26 @@ case "`uname`" in
;;
esac

set_jdk_java_home_from_env_vars() {
# 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
}

set_jdk_java_home(){
# After loading visualvm.conf , check if visualvm_jdkhome defined & its valid. Else fallback to jdk env
if [ -n "${visualvm_jdkhome}" ] && [ -d "${visualvm_jdkhome}" ] && [ -f "${visualvm_jdkhome}/bin/java" ]; then
: # No-Op
else
set_jdk_java_home_from_env_vars
fi
}

if [ -f "$progdir"/../lib/visualvm/etc/visualvm.conf ] ; then
visualvm_jdkhome="$basedir"
old=`pwd`
cd "$progdir/../lib/visualvm/"
basedir=`pwd`
Expand All @@ -73,6 +90,7 @@ elif [ -f "$progdir"/../etc/visualvm.conf ] ; then
. "$progdir"/../etc/visualvm.conf
fi

set_jdk_java_home

export DEFAULT_USERDIR_ROOT

Expand Down