From 9ef6843d3bbbff5b196dbb3ecf5c3b00e7747d4e Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 14:45:07 +0800 Subject: [PATCH 01/23] update script (cherry picked from commit 19fb3c8d44bfe43c1b8871d7ff34e3b057be5de0) --- install_dependencies.sh | 470 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 440 insertions(+), 30 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 860e79440e..0669d3a386 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -5,19 +5,327 @@ set -e OS="$(uname -s)" ARCH="$(uname -m)" -echo ">>> Environment Detection" +echo "========================================" +echo " TRON Java Dependencies Installer" +echo "========================================" +echo "" +echo -e ">>> \033[1mEnvironment Detection\033[0m" if [[ "$OS" == "Darwin" ]]; then echo " OS: MacOS $OS" elif [[ "$OS" == "Linux" ]]; then echo " OS: $OS" fi echo " Architecture: $ARCH" -echo "----------------------------------------" -echo ">>> Note: This script has been tested on:" +echo "" +echo ">>> This script will install the following components if not already installed:" +echo " 1. Homebrew to download and install JDK (macOS only)" +echo " 2. Git for cloning the java-tron repository" +if [[ "$OS" == "Darwin" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + echo " 3. OpenJDK 8 (required for x86_64 architecture)" + elif [[ "$ARCH" == "arm64" ]]; then + echo " 3. OpenJDK 17 (required for arm64 architecture)" + fi +elif [[ "$OS" == "Linux" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + echo " 3. OpenJDK 8 (required for x86_64 architecture)" + elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then + echo " 3. OpenJDK 17 (required for arm64/aarch64 architecture)" + fi +fi +echo "" +echo ">>> Tested platforms:" echo " - macOS x86_64 (JDK 8)" echo " - macOS arm64 (JDK 17)" echo " - Linux x86_64 (generic, including Ubuntu) (JDK 8)" echo " - Linux arm64/aarch64 (generic, including Ubuntu) (JDK 17)" +echo "" +echo "⚠️ WARNING: By continuing, you agree to install the above components." +echo " This script may install new software and modify your system Java environment." +echo "" + +# Function to ask for user confirmation +ask_confirmation() { + while true; do + read -p "Do you want to continue? (y/N): " yn + case $yn in + [Yy]* ) return 0;; + [Nn]* | "" ) echo "Installation cancelled."; exit 0;; + * ) echo "Please answer yes (y) or no (n).";; + esac + done +} + +# Function to check Java version +check_java_version() { + if command -v java &> /dev/null; then + local java_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + echo " Current Java version: $java_version" + + # Check if it's JDK 8 (version starts with 1.8) + if [[ "$java_version" =~ ^1\.8\. ]]; then + echo " JDK 8 is already installed." + return 0 + # Check if it's JDK 17 (version starts with 17) + elif [[ "$java_version" =~ ^17\. ]]; then + echo " JDK 17 is already installed." + return 1 + else + echo " Different Java version detected: $java_version" + return 2 + fi + else + echo " No Java installation found." + return 3 + fi +} + +# Function to ask for JDK installation confirmation +ask_jdk_confirmation() { + local current_version="$1" + local required_version="$2" + local arch="$3" + + echo "" + echo "⚠️ JDK Version Mismatch Detected!" + echo " Current version: $current_version" + echo " Required version for $arch: $required_version" + echo " This script will install $required_version alongside your existing installation." + echo " Your current Java installation will not be removed." + echo "" + + while true; do + read -p "Do you want to install $required_version? (y/N): " yn + case $yn in + [Yy]* ) return 0;; + [Nn]* | "" ) echo "JDK installation cancelled. Exiting."; exit 0;; + * ) echo "Please answer yes (y) or no (n).";; + esac + done +} + +# First, check and install Git (needed for cloning repository) +echo -e ">>> \033[1mChecking Git installation...\033[0m" +if ! command -v git &> /dev/null; then + echo " Git is not installed." + while true; do + read -p "Do you want to install Git (required for cloning the java-tron repository)? (y/N): " yn + case $yn in + [Yy]* ) + echo ">>> Installing Git..." + INSTALL_GIT=true + break;; + [Nn]* | "" ) + echo "Git installation cancelled. You'll need Git to clone the java-tron repository." + echo "You can install Git manually later and then clone the repository." + INSTALL_GIT=false + break;; + * ) echo "Please answer yes (y) or no (n).";; + esac + done +else + echo " ✅ Git is already installed: $(git --version)" + INSTALL_GIT=false +fi + +echo "" +echo -e ">>> \033[1mChecking existing Java installation...\033[0m" +set +e # Temporarily disable exit on error +check_java_version +java_status=$? +set -e # Re-enable exit on error + +# Determine required JDK version based on architecture +if [[ "$OS" == "Darwin" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + required_jdk="JDK 8" + required_status=0 + elif [[ "$ARCH" == "arm64" ]]; then + required_jdk="JDK 17" + required_status=1 + else + echo "Error: Unsupported architecture for macOS: $ARCH" + exit 1 + fi +elif [[ "$OS" == "Linux" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + required_jdk="JDK 8" + required_status=0 + elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then + required_jdk="JDK 17" + required_status=1 + else + echo "Error: Unsupported architecture for Linux: $ARCH" + exit 1 + fi +else + echo "Error: Unsupported Operating System: $OS" + exit 1 +fi + +# Check if correct JDK version is already installed +if [[ $java_status -eq $required_status ]]; then + echo "✅ Correct Java version ($required_jdk) is already installed!" + echo " You can skip the Java installation part." + echo "" + if [[ "$INSTALL_GIT" == "false" ]]; then + echo "✅ Both Git and Java JDK are ready for TRON development!" + echo "" + exit 0 + else + echo ">>> Proceeding with Git installation only..." + SKIP_JAVA_INSTALL=true + fi +elif [[ $java_status -eq 0 ]] || [[ $java_status -eq 1 ]] || [[ $java_status -eq 2 ]]; then + # Different JDK version is installed, ask for confirmation + current_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + ask_jdk_confirmation "$current_version" "$required_jdk" "$ARCH" + SKIP_JAVA_INSTALL=false +else + # No Java installation found, ask for general confirmation + echo "" + echo "⚠️ No Java installation detected!" + echo " This script will install $required_jdk which is required for $ARCH architecture." + echo "" + ask_confirmation + SKIP_JAVA_INSTALL=false +fi + +# Unified Java environment configuration function +configure_java_environment() { + local jdk_version="$1" + local os_type="$2" + local arch="$3" + local java_home="" + local java_bin_path="" + + echo "" + echo -e "==> \033[1mConfiguring Java environment\033[0m for JDK $jdk_version..." + + # Determine Java paths based on OS and architecture + if [[ "$os_type" == "Darwin" ]]; then + # macOS paths + if [[ "$jdk_version" == "8" ]]; then + java_home="/usr/local/opt/openjdk@8" + java_bin_path="/usr/local/opt/openjdk@8/bin" + elif [[ "$jdk_version" == "17" ]]; then + if [[ "$arch" == "arm64" ]]; then + java_home="/opt/homebrew/opt/openjdk@17" + java_bin_path="/opt/homebrew/opt/openjdk@17/bin" + else + java_home="/usr/local/opt/openjdk@17" + java_bin_path="/usr/local/opt/openjdk@17/bin" + fi + fi + elif [[ "$os_type" == "Linux" ]]; then + # Linux paths + if [[ "$jdk_version" == "8" ]]; then + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "arm64" ]]; then + java_home="/usr/lib/jvm/java-8-openjdk-arm64" + else + java_home="/usr/lib/jvm/java-8-openjdk-amd64" + fi + else + # RHEL/CentOS/Amazon Linux - try multiple possible paths + for path in "/usr/lib/jvm/java-1.8.0-amazon-corretto" "/usr/lib/jvm/java-1.8.0-openjdk"; do + if [[ -d "$path" ]]; then + java_home="$path" + break + fi + done + fi + elif [[ "$jdk_version" == "17" ]]; then + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "arm64" ]]; then + java_home="/usr/lib/jvm/java-17-openjdk-arm64" + else + java_home="/usr/lib/jvm/java-17-openjdk-amd64" + fi + else + # RHEL/CentOS/Amazon Linux - try multiple possible paths + for path in "/usr/lib/jvm/java-17-amazon-corretto" "/usr/lib/jvm/java-17-openjdk"; do + if [[ -d "$path" ]]; then + java_home="$path" + break + fi + done + fi + fi + java_bin_path="$java_home/bin" + fi + + # Set environment variables for current session + if [[ -d "$java_home" ]]; then + export JAVA_HOME="$java_home" + export PATH="$java_bin_path:$PATH" + echo " ✅ JAVA_HOME set to: $JAVA_HOME" + echo " ✅ PATH updated to include: $java_bin_path" + echo " 🔄 Environment temporarily configured for JDK $jdk_version" + + # Create a source script for the user's current shell + local env_script="./tron_java_env.sh" + cat > "$env_script" << EOF + +#!/bin/bash +# TRON Java Environment Configuration +# Generated by install_dependencies.sh on $(date) + +export JAVA_HOME="$java_home" +export PATH="$java_bin_path:\$PATH" + +echo "✅ Java environment configured:" +echo " JAVA_HOME: \$JAVA_HOME" +echo " Java version: \$(java -version 2>&1 | head -n 1)" +EOF + chmod +x "$env_script" + + echo "" + echo " 🎯 To apply Java environment to your current shell session:" + echo " source ./tron_java_env.sh" + echo "" + echo " 💡 Or run this command directly:" + echo " export JAVA_HOME=\"$java_home\"" + echo " export PATH=\"$java_bin_path:\$PATH\"" + + else + echo " ⚠️ Could not find Java installation at expected path: $java_home" + echo " ⚠️ You may need to set JAVA_HOME manually" + return 1 + fi + + # Provide OS-specific permanent configuration instructions + echo "" + echo " ⚙️ To make JDK $jdk_version permanent:" + if [[ "$os_type" == "Darwin" ]]; then + echo " # Add to ~/.zshrc or ~/.bash_profile:" + echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.zshrc" + echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.zshrc" + echo " # Then run below command:" + echo " source ~/.zshrc" + echo "" + elif [[ "$os_type" == "Linux" ]]; then + echo " # Method 1: Add to ~/.bashrc:" + echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.bashrc" + echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.bashrc" + echo " source ~/.bashrc" + echo "" + echo " # Method 2: Use update-alternatives (recommended):" + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + echo " sudo update-alternatives --install /usr/bin/java java $java_bin_path/java 1" + echo " sudo update-alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" + echo " sudo update-alternatives --config java" + else + echo " sudo alternatives --install /usr/bin/java java $java_bin_path/java 1" + echo " sudo alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" + echo " sudo alternatives --config java" + fi + fi + echo "" + + return 0 +} + echo "----------------------------------------" install_macos() { @@ -31,29 +339,73 @@ install_macos() { else eval "$(/usr/local/bin/brew shellenv)" fi + else + echo ">>> Homebrew is already installed." fi echo ">>> Updating Homebrew..." brew update - echo ">>> Installing Git..." - brew install git + # Install Git if needed + if [[ "$INSTALL_GIT" == "true" ]]; then + echo ">>> Installing Git..." + brew install git + echo " ✅ Git installed successfully: $(git --version)" + fi + + # Skip Java installation if flag is set + if [[ "$SKIP_JAVA_INSTALL" == "true" ]]; then + echo ">>> Skipping Java installation (correct version already detected)." + return 0 + fi if [[ "$ARCH" == "x86_64" ]]; then - echo ">>> Architecture is x86_64. Installing JDK 8..." - brew install openjdk@8 + echo ">>> Architecture is x86_64. Checking for JDK 8..." + set +e # Temporarily disable exit on error + check_java_version + local java_status=$? + set -e # Re-enable exit on error - echo ">>> Configuring PATH for openjdk@8 in this script session..." - export PATH="/usr/local/opt/openjdk@8/bin:$PATH" - echo " PATH updated to include /usr/local/opt/openjdk@8/bin" + if [[ $java_status -eq 0 ]]; then + echo ">>> JDK 8 is already installed. Skipping installation." + else + if [[ $java_status -eq 1 ]]; then + echo ">>> Installing JDK 8 alongside existing JDK 17..." + elif [[ $java_status -eq 2 ]]; then + echo ">>> Installing JDK 8 alongside existing Java installation..." + else + echo ">>> Installing JDK 8..." + fi + brew install openjdk@8 + + # Use unified Java environment configuration + configure_java_environment "8" "Darwin" "$ARCH" + echo "🔄 Environment has been updated! Java 8(1.8.*) is now configured." + fi elif [[ "$ARCH" == "arm64" ]]; then - echo ">>> Architecture is arm64. Installing JDK 17..." - brew install openjdk@17 + echo ">>> Architecture is arm64. Checking for JDK 17..." + set +e # Temporarily disable exit on error + check_java_version + local java_status=$? + set -e # Re-enable exit on error + + if [[ $java_status -eq 1 ]]; then + echo ">>> JDK 17 is already installed. Skipping installation." + else + if [[ $java_status -eq 0 ]]; then + echo ">>> Installing JDK 17 alongside existing JDK 8..." + elif [[ $java_status -eq 2 ]]; then + echo ">>> Installing JDK 17 alongside existing Java installation..." + else + echo ">>> Installing JDK 17..." + fi + brew install openjdk@17 - echo ">>> Configuring PATH for openjdk@17 in this script session..." - export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" - echo " PATH updated to include /opt/homebrew/opt/openjdk@17/bin" + # Use unified Java environment configuration + configure_java_environment "17" "Darwin" "$ARCH" + echo "🔄 Environment has been updated! Java 17 is now configured." + fi else echo "Error: Unsupported architecture for macOS script: $ARCH" @@ -82,8 +434,18 @@ install_linux() { echo ">>> Updating package index ($PKG_MANAGER)..." $UPDATE_CMD || true - echo ">>> Installing Git..." - $INSTALL_CMD git + # Install Git if needed + if [[ "$INSTALL_GIT" == "true" ]]; then + echo ">>> Installing Git..." + $INSTALL_CMD git + echo " ✅ Git installed successfully: $(git --version)" + fi + + # Skip Java installation if flag is set + if [[ "$SKIP_JAVA_INSTALL" == "true" ]]; then + echo ">>> Skipping Java installation (correct version already detected)." + return 0 + fi install_first_available() { for pkg in "$@"; do @@ -95,19 +457,61 @@ install_linux() { } if [[ "$ARCH" == "x86_64" ]]; then - echo ">>> Architecture is x86_64. Installing JDK 8..." - if [[ "$PKG_MANAGER" == "apt-get" ]]; then - install_first_available openjdk-8-jdk + echo ">>> Architecture is x86_64. Checking for JDK 8..." + set +e # Temporarily disable exit on error + check_java_version + local java_status=$? + set -e # Re-enable exit on error + + if [[ $java_status -eq 0 ]]; then + echo ">>> JDK 8 is already installed. Skipping installation." else - install_first_available java-1.8.0-amazon-corretto-devel java-1.8.0-openjdk-devel - fi || { echo "Error: Unable to install JDK 8 on $PKG_MANAGER"; exit 1; } + if [[ $java_status -eq 1 ]]; then + echo ">>> Installing JDK 8 alongside existing JDK 17..." + elif [[ $java_status -eq 2 ]]; then + echo ">>> Installing JDK 8 alongside existing Java installation..." + else + echo ">>> Installing JDK 8..." + fi + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + install_first_available openjdk-8-jdk + else + install_first_available java-1.8.0-amazon-corretto-devel java-1.8.0-openjdk-devel + fi || { echo "Error: Unable to install JDK 8 on $PKG_MANAGER"; exit 1; } + + # Use unified Java environment configuration + configure_java_environment "8" "Linux" "$ARCH" + echo "🔄 Environment has been updated! Java 8(1.8.*) is now configured." + fi + elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then - echo ">>> Architecture is arm64/aarch64. Installing JDK 17..." - if [[ "$PKG_MANAGER" == "apt-get" ]]; then - install_first_available openjdk-17-jdk + echo ">>> Architecture is arm64/aarch64. Checking for JDK 17..." + set +e # Temporarily disable exit on error + check_java_version + local java_status=$? + set -e # Re-enable exit on error + + if [[ $java_status -eq 1 ]]; then + echo ">>> JDK 17 is already installed. Skipping installation." else - install_first_available java-17-amazon-corretto-devel java-17-openjdk-devel - fi || { echo "Error: Unable to install JDK 17 on $PKG_MANAGER"; exit 1; } + if [[ $java_status -eq 0 ]]; then + echo ">>> Installing JDK 17 alongside existing JDK 8..." + elif [[ $java_status -eq 2 ]]; then + echo ">>> Installing JDK 17 alongside existing Java installation..." + else + echo ">>> Installing JDK 17..." + fi + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + install_first_available openjdk-17-jdk + else + install_first_available java-17-amazon-corretto-devel java-17-openjdk-devel + fi || { echo "Error: Unable to install JDK 17 on $PKG_MANAGER"; exit 1; } + + # Use unified Java environment configuration + configure_java_environment "17" "Linux" "$ARCH" + echo "🔄 Environment has been updated! Java 17 is now configured." + fi + else echo "Error: Unsupported architecture for Linux script: $ARCH" exit 1 @@ -124,8 +528,14 @@ else fi echo "----------------------------------------" -echo ">>> Installation logic completed." -echo "Please verify installations manually if any errors occurred above." -echo "Check versions with:" +echo -e "✅ \033[1mInstallation completed successfully!\033[0m" +echo "" +echo ">>> Verification Commands:" echo " git --version" echo " java -version" +echo "" +echo ">>> Troubleshooting:" +echo -e " • If 'java -version' shows incorrect version, check \033[1mConfiguring Java environment\033[0m instructions shown above " +echo "" +echo "🎉 Your development environment is ready for TRON!" +echo "" \ No newline at end of file From 1b1d32734f04982524fe09e3e1ab9963af702752 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 14:52:09 +0800 Subject: [PATCH 02/23] fix minors --- install_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 0669d3a386..cdb53c4cf5 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -535,7 +535,7 @@ echo " git --version" echo " java -version" echo "" echo ">>> Troubleshooting:" -echo -e " • If 'java -version' shows incorrect version, check \033[1mConfiguring Java environment\033[0m instructions shown above " +echo -e " • If 'java -version' shows incorrect version, check \033[1mConfiguring Java environment\033[0m instructions shown above." echo "" echo "🎉 Your development environment is ready for TRON!" echo "" \ No newline at end of file From 2dd181ff66a5609b10f2177e36d1558251464640 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 14:56:36 +0800 Subject: [PATCH 03/23] fix texts --- install_dependencies.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index cdb53c4cf5..7b3aaa1021 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -75,7 +75,6 @@ check_java_version() { return 2 fi else - echo " No Java installation found." return 3 fi } From c55deb9251e5d9c2802d04d91e73e284414041e2 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 15:27:50 +0800 Subject: [PATCH 04/23] update --- install_dependencies.sh | 247 +++++++++++++++++++++++++++------------- tron_java_env.sh | 11 ++ 2 files changed, 182 insertions(+), 76 deletions(-) create mode 100755 tron_java_env.sh diff --git a/install_dependencies.sh b/install_dependencies.sh index 7b3aaa1021..fa35421dbc 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -17,6 +17,12 @@ elif [[ "$OS" == "Linux" ]]; then fi echo " Architecture: $ARCH" echo "" +echo ">>> Tested platforms:" +echo " - macOS x86_64 (JDK 8)" +echo " - macOS arm64 (JDK 17)" +echo " - Linux x86_64 (generic, including Ubuntu) (JDK 8)" +echo " - Linux arm64/aarch64 (generic, including Ubuntu) (JDK 17)" +echo "" echo ">>> This script will install the following components if not already installed:" echo " 1. Homebrew to download and install JDK (macOS only)" echo " 2. Git for cloning the java-tron repository" @@ -34,14 +40,7 @@ elif [[ "$OS" == "Linux" ]]; then fi fi echo "" -echo ">>> Tested platforms:" -echo " - macOS x86_64 (JDK 8)" -echo " - macOS arm64 (JDK 17)" -echo " - Linux x86_64 (generic, including Ubuntu) (JDK 8)" -echo " - Linux arm64/aarch64 (generic, including Ubuntu) (JDK 17)" -echo "" -echo "⚠️ WARNING: By continuing, you agree to install the above components." -echo " This script may install new software and modify your system Java environment." +echo "WARNING: By continuing, you agree to install the above components." echo "" # Function to ask for user confirmation @@ -55,6 +54,7 @@ ask_confirmation() { esac done } +ask_confirmation # Function to check Java version check_java_version() { @@ -86,7 +86,7 @@ ask_jdk_confirmation() { local arch="$3" echo "" - echo "⚠️ JDK Version Mismatch Detected!" + echo "JDK Version Mismatch Detected!" echo " Current version: $current_version" echo " Required version for $arch: $required_version" echo " This script will install $required_version alongside your existing installation." @@ -123,7 +123,7 @@ if ! command -v git &> /dev/null; then esac done else - echo " ✅ Git is already installed: $(git --version)" + echo "Git is already installed: $(git --version)" INSTALL_GIT=false fi @@ -164,11 +164,11 @@ fi # Check if correct JDK version is already installed if [[ $java_status -eq $required_status ]]; then - echo "✅ Correct Java version ($required_jdk) is already installed!" + echo "Correct Java version ($required_jdk) is already installed!" echo " You can skip the Java installation part." echo "" if [[ "$INSTALL_GIT" == "false" ]]; then - echo "✅ Both Git and Java JDK are ready for TRON development!" + echo "Both Git and Java JDK are ready for TRON development!" echo "" exit 0 else @@ -183,41 +183,155 @@ elif [[ $java_status -eq 0 ]] || [[ $java_status -eq 1 ]] || [[ $java_status -eq else # No Java installation found, ask for general confirmation echo "" - echo "⚠️ No Java installation detected!" + echo "No Java installation detected!" echo " This script will install $required_jdk which is required for $ARCH architecture." echo "" - ask_confirmation SKIP_JAVA_INSTALL=false fi -# Unified Java environment configuration function -configure_java_environment() { +# Function to show permanent Java configuration instructions +show_permanent_java_config() { local jdk_version="$1" local os_type="$2" - local arch="$3" - local java_home="" - local java_bin_path="" + local java_home="$3" + local java_bin_path="$4" + + echo "" + echo " To make JDK $jdk_version permanent:" + if [[ "$os_type" == "Darwin" ]]; then + echo " # Add to ~/.zshrc or ~/.bash_profile:" + echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.zshrc" + echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.zshrc" + echo " # Then run below command:" + echo " source ~/.zshrc" + echo "" + echo " # Or use jenv for Java version management:" + echo " brew install jenv" + echo " jenv add $java_home" + elif [[ "$os_type" == "Linux" ]]; then + echo " # Method 1: Add to ~/.bashrc:" + echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.bashrc" + echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.bashrc" + echo " source ~/.bashrc" + echo "" + echo " # Method 2: Use update-alternatives (recommended):" + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + echo " sudo update-alternatives --install /usr/bin/java java $java_bin_path/java 1" + echo " sudo update-alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" + echo " sudo update-alternatives --config java" + else + echo " sudo alternatives --install /usr/bin/java java $java_bin_path/java 1" + echo " sudo alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" + echo " sudo alternatives --config java" + fi + fi + echo "" +} +# Function to show Java environment application instructions +show_java_env_instructions() { + local java_home="$1" + local java_bin_path="$2" + + echo "" + echo " To apply Java environment to your current shell session:" + echo " source ./tron_java_env.sh" echo "" - echo -e "==> \033[1mConfiguring Java environment\033[0m for JDK $jdk_version..." + echo " Or run this command directly:" + echo " export JAVA_HOME=\"$java_home\"" + echo " export PATH=\"$java_bin_path:\$PATH\"" +} + +# Function to get Java paths based on OS and architecture +get_java_paths() { + local jdk_version="$1" + local os_type="$2" + local arch="$3" + local java_home="" - # Determine Java paths based on OS and architecture if [[ "$os_type" == "Darwin" ]]; then # macOS paths if [[ "$jdk_version" == "8" ]]; then java_home="/usr/local/opt/openjdk@8" - java_bin_path="/usr/local/opt/openjdk@8/bin" elif [[ "$jdk_version" == "17" ]]; then if [[ "$arch" == "arm64" ]]; then java_home="/opt/homebrew/opt/openjdk@17" - java_bin_path="/opt/homebrew/opt/openjdk@17/bin" else java_home="/usr/local/opt/openjdk@17" - java_bin_path="/usr/local/opt/openjdk@17/bin" fi fi elif [[ "$os_type" == "Linux" ]]; then - # Linux paths + # Linux paths - provide generic path for manual configuration + java_home="/usr/lib/jvm/java-$jdk_version-openjdk" + fi + + echo "$java_home" +} + +# Unified Java environment configuration function +configure_java_environment() { + local jdk_version="$1" + local os_type="$2" + local arch="$3" + local java_home="" + local java_bin_path="" + + echo "" + echo -e ">>> \033[1mConfiguring Java environment\033[0m for JDK $jdk_version..." + + # Ask user for confirmation before changing environment + echo "" + echo "This will modify your Java environment settings:" + echo " • Set JAVA_HOME to the new JDK $jdk_version installation" + echo " • Update PATH to include the new Java binaries" + echo " • Create a script (tron_java_env.sh) for easy environment setup" + echo "" + + while true; do + read -p "Do you want to configure the Java environment for JDK $jdk_version? (y/N): " yn + case $yn in + [Yy]* ) + echo ">>> Proceeding with Java environment configuration..." + break;; + [Nn]* | "" ) + echo "Java environment configuration skipped." + echo "You may need to manually set JAVA_HOME and PATH for JDK $jdk_version" + echo "" + echo "Manual configuration commands:" + + # Get the expected Java path + local expected_java_home=$(get_java_paths "$jdk_version" "$os_type" "$arch") + local expected_java_bin_path="$expected_java_home/bin" + echo " export JAVA_HOME=\"$expected_java_home\"" + echo " export PATH=\"\$JAVA_HOME/bin:\$PATH\"" + + if [[ "$os_type" == "Linux" ]]; then + echo "" + echo "Note: Actual path may vary depending on your distribution." + echo "Common paths include:" + echo " /usr/lib/jvm/java-$jdk_version-openjdk-amd64 (Ubuntu/Debian)" + echo " /usr/lib/jvm/java-1.$jdk_version.0-openjdk (RHEL/CentOS)" + fi + + # Show the same application instructions as automatic configuration + show_java_env_instructions "$expected_java_home" "$expected_java_bin_path" + + # Show permanent configuration instructions + show_permanent_java_config "$jdk_version" "$os_type" "$expected_java_home" "$expected_java_bin_path" + + echo "" + return 1;; + * ) echo "Please answer yes (y) or no (n).";; + esac + done + + # Determine Java paths based on OS and architecture + if [[ "$os_type" == "Darwin" ]]; then + # Use the helper function for macOS + java_home=$(get_java_paths "$jdk_version" "$os_type" "$arch") + java_bin_path="$java_home/bin" + elif [[ "$os_type" == "Linux" ]]; then + # Linux paths - try to find the actual installation if [[ "$jdk_version" == "8" ]]; then if [[ "$PKG_MANAGER" == "apt-get" ]]; then if [[ "$arch" == "aarch64" ]] || [[ "$arch" == "arm64" ]]; then @@ -258,9 +372,9 @@ configure_java_environment() { if [[ -d "$java_home" ]]; then export JAVA_HOME="$java_home" export PATH="$java_bin_path:$PATH" - echo " ✅ JAVA_HOME set to: $JAVA_HOME" - echo " ✅ PATH updated to include: $java_bin_path" - echo " 🔄 Environment temporarily configured for JDK $jdk_version" + echo " JAVA_HOME set to: $JAVA_HOME" + echo " PATH updated to include: $java_bin_path" + echo " Environment temporarily configured for JDK $jdk_version" # Create a source script for the user's current shell local env_script="./tron_java_env.sh" @@ -273,54 +387,23 @@ configure_java_environment() { export JAVA_HOME="$java_home" export PATH="$java_bin_path:\$PATH" -echo "✅ Java environment configured:" +echo "Java environment configured:" echo " JAVA_HOME: \$JAVA_HOME" echo " Java version: \$(java -version 2>&1 | head -n 1)" EOF chmod +x "$env_script" echo "" - echo " 🎯 To apply Java environment to your current shell session:" - echo " source ./tron_java_env.sh" - echo "" - echo " 💡 Or run this command directly:" - echo " export JAVA_HOME=\"$java_home\"" - echo " export PATH=\"$java_bin_path:\$PATH\"" + show_java_env_instructions "$java_home" "$java_bin_path" else - echo " ⚠️ Could not find Java installation at expected path: $java_home" - echo " ⚠️ You may need to set JAVA_HOME manually" + echo " Could not find Java installation at expected path: $java_home" + echo " You may need to set JAVA_HOME manually" return 1 fi # Provide OS-specific permanent configuration instructions - echo "" - echo " ⚙️ To make JDK $jdk_version permanent:" - if [[ "$os_type" == "Darwin" ]]; then - echo " # Add to ~/.zshrc or ~/.bash_profile:" - echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.zshrc" - echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.zshrc" - echo " # Then run below command:" - echo " source ~/.zshrc" - echo "" - elif [[ "$os_type" == "Linux" ]]; then - echo " # Method 1: Add to ~/.bashrc:" - echo " echo 'export JAVA_HOME=\"$java_home\"' >> ~/.bashrc" - echo " echo 'export PATH=\"\$JAVA_HOME/bin:\$PATH\"' >> ~/.bashrc" - echo " source ~/.bashrc" - echo "" - echo " # Method 2: Use update-alternatives (recommended):" - if [[ "$PKG_MANAGER" == "apt-get" ]]; then - echo " sudo update-alternatives --install /usr/bin/java java $java_bin_path/java 1" - echo " sudo update-alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" - echo " sudo update-alternatives --config java" - else - echo " sudo alternatives --install /usr/bin/java java $java_bin_path/java 1" - echo " sudo alternatives --install /usr/bin/javac javac $java_bin_path/javac 1" - echo " sudo alternatives --config java" - fi - fi - echo "" + show_permanent_java_config "$jdk_version" "$os_type" "$java_home" "$java_bin_path" return 0 } @@ -349,7 +432,7 @@ install_macos() { if [[ "$INSTALL_GIT" == "true" ]]; then echo ">>> Installing Git..." brew install git - echo " ✅ Git installed successfully: $(git --version)" + echo " Git installed successfully: $(git --version)" fi # Skip Java installation if flag is set @@ -378,8 +461,11 @@ install_macos() { brew install openjdk@8 # Use unified Java environment configuration - configure_java_environment "8" "Darwin" "$ARCH" - echo "🔄 Environment has been updated! Java 8(1.8.*) is now configured." + if configure_java_environment "8" "Darwin" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + fi fi elif [[ "$ARCH" == "arm64" ]]; then @@ -402,8 +488,11 @@ install_macos() { brew install openjdk@17 # Use unified Java environment configuration - configure_java_environment "17" "Darwin" "$ARCH" - echo "🔄 Environment has been updated! Java 17 is now configured." + if configure_java_environment "17" "Darwin" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + fi fi else @@ -437,7 +526,7 @@ install_linux() { if [[ "$INSTALL_GIT" == "true" ]]; then echo ">>> Installing Git..." $INSTALL_CMD git - echo " ✅ Git installed successfully: $(git --version)" + echo " Git installed successfully: $(git --version)" fi # Skip Java installation if flag is set @@ -479,8 +568,11 @@ install_linux() { fi || { echo "Error: Unable to install JDK 8 on $PKG_MANAGER"; exit 1; } # Use unified Java environment configuration - configure_java_environment "8" "Linux" "$ARCH" - echo "🔄 Environment has been updated! Java 8(1.8.*) is now configured." + if configure_java_environment "8" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + fi fi elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then @@ -507,8 +599,11 @@ install_linux() { fi || { echo "Error: Unable to install JDK 17 on $PKG_MANAGER"; exit 1; } # Use unified Java environment configuration - configure_java_environment "17" "Linux" "$ARCH" - echo "🔄 Environment has been updated! Java 17 is now configured." + if configure_java_environment "17" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + fi fi else @@ -527,7 +622,7 @@ else fi echo "----------------------------------------" -echo -e "✅ \033[1mInstallation completed successfully!\033[0m" +echo -e "\033[1mInstallation completed successfully!\033[0m" echo "" echo ">>> Verification Commands:" echo " git --version" @@ -536,5 +631,5 @@ echo "" echo ">>> Troubleshooting:" echo -e " • If 'java -version' shows incorrect version, check \033[1mConfiguring Java environment\033[0m instructions shown above." echo "" -echo "🎉 Your development environment is ready for TRON!" +echo "Your development environment is ready for TRON!" echo "" \ No newline at end of file diff --git a/tron_java_env.sh b/tron_java_env.sh new file mode 100755 index 0000000000..9a213d09ea --- /dev/null +++ b/tron_java_env.sh @@ -0,0 +1,11 @@ + +#!/bin/bash +# TRON Java Environment Configuration +# Generated by install_dependencies.sh on Thu Jan 22 15:27:00 +08 2026 + +export JAVA_HOME="/opt/homebrew/opt/openjdk@17" +export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" + +echo "Java environment configured:" +echo " JAVA_HOME: $JAVA_HOME" +echo " Java version: $(java -version 2>&1 | head -n 1)" From 0d1394f291c40afe94719642758c6137a7a9ab08 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 15:55:45 +0800 Subject: [PATCH 05/23] delete first confirm --- install_dependencies.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index fa35421dbc..2a58a68998 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -54,7 +54,6 @@ ask_confirmation() { esac done } -ask_confirmation # Function to check Java version check_java_version() { From af35af5565108dcfec3af1f5e30aa769eb89fe56 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 15:58:35 +0800 Subject: [PATCH 06/23] delete text --- install_dependencies.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 2a58a68998..0cc71bb402 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -40,8 +40,6 @@ elif [[ "$OS" == "Linux" ]]; then fi fi echo "" -echo "WARNING: By continuing, you agree to install the above components." -echo "" # Function to ask for user confirmation ask_confirmation() { @@ -185,6 +183,7 @@ else echo "No Java installation detected!" echo " This script will install $required_jdk which is required for $ARCH architecture." echo "" + ask_confirmation SKIP_JAVA_INSTALL=false fi From ae8cb7fbbe8ee3236cc4badd5f80c4f53197ff16 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 16:11:18 +0800 Subject: [PATCH 07/23] fix format --- install_dependencies.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 0cc71bb402..1f1d2268a5 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -9,7 +9,7 @@ echo "========================================" echo " TRON Java Dependencies Installer" echo "========================================" echo "" -echo -e ">>> \033[1mEnvironment Detection\033[0m" +echo ">>> Environment Detection" if [[ "$OS" == "Darwin" ]]; then echo " OS: MacOS $OS" elif [[ "$OS" == "Linux" ]]; then @@ -22,6 +22,7 @@ echo " - macOS x86_64 (JDK 8)" echo " - macOS arm64 (JDK 17)" echo " - Linux x86_64 (generic, including Ubuntu) (JDK 8)" echo " - Linux arm64/aarch64 (generic, including Ubuntu) (JDK 17)" +echo " Note: Other platforms may require manual installation if errors occur" echo "" echo ">>> This script will install the following components if not already installed:" echo " 1. Homebrew to download and install JDK (macOS only)" @@ -101,7 +102,7 @@ ask_jdk_confirmation() { } # First, check and install Git (needed for cloning repository) -echo -e ">>> \033[1mChecking Git installation...\033[0m" +echo ">>> Checking Git installation..." if ! command -v git &> /dev/null; then echo " Git is not installed." while true; do @@ -125,7 +126,7 @@ else fi echo "" -echo -e ">>> \033[1mChecking existing Java installation...\033[0m" +echo ">>> Checking existing Java installation..." set +e # Temporarily disable exit on error check_java_version java_status=$? @@ -161,7 +162,6 @@ fi # Check if correct JDK version is already installed if [[ $java_status -eq $required_status ]]; then - echo "Correct Java version ($required_jdk) is already installed!" echo " You can skip the Java installation part." echo "" if [[ "$INSTALL_GIT" == "false" ]]; then @@ -275,14 +275,14 @@ configure_java_environment() { local java_bin_path="" echo "" - echo -e ">>> \033[1mConfiguring Java environment\033[0m for JDK $jdk_version..." + echo ">>> Configuring Java environment for JDK $jdk_version..." # Ask user for confirmation before changing environment echo "" echo "This will modify your Java environment settings:" - echo " • Set JAVA_HOME to the new JDK $jdk_version installation" - echo " • Update PATH to include the new Java binaries" - echo " • Create a script (tron_java_env.sh) for easy environment setup" + echo " - Set JAVA_HOME to the new JDK $jdk_version installation" + echo " - Update PATH to include the new Java binaries" + echo " - Create a script (tron_java_env.sh) for easy environment setup" echo "" while true; do @@ -620,14 +620,14 @@ else fi echo "----------------------------------------" -echo -e "\033[1mInstallation completed successfully!\033[0m" +echo "Installation completed successfully!" echo "" echo ">>> Verification Commands:" echo " git --version" echo " java -version" echo "" echo ">>> Troubleshooting:" -echo -e " • If 'java -version' shows incorrect version, check \033[1mConfiguring Java environment\033[0m instructions shown above." +echo " - If 'java -version' shows incorrect version, check Configuring Java environment instructions shown above." echo "" echo "Your development environment is ready for TRON!" echo "" \ No newline at end of file From c8a439445c9428243784a96a6f392d3de9bb9cd7 Mon Sep 17 00:00:00 2001 From: Edward Date: Thu, 22 Jan 2026 16:14:17 +0800 Subject: [PATCH 08/23] Delete tron_java_env.sh --- tron_java_env.sh | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100755 tron_java_env.sh diff --git a/tron_java_env.sh b/tron_java_env.sh deleted file mode 100755 index 9a213d09ea..0000000000 --- a/tron_java_env.sh +++ /dev/null @@ -1,11 +0,0 @@ - -#!/bin/bash -# TRON Java Environment Configuration -# Generated by install_dependencies.sh on Thu Jan 22 15:27:00 +08 2026 - -export JAVA_HOME="/opt/homebrew/opt/openjdk@17" -export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" - -echo "Java environment configured:" -echo " JAVA_HOME: $JAVA_HOME" -echo " Java version: $(java -version 2>&1 | head -n 1)" From cee43ece1d17d7ae34a52aa903b64fc6ef362691 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 16:21:04 +0800 Subject: [PATCH 09/23] fix git comments --- install_dependencies.sh | 2 +- tron_java_env.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 1f1d2268a5..3c7292b302 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -26,7 +26,7 @@ echo " Note: Other platforms may require manual installation if errors occur" echo "" echo ">>> This script will install the following components if not already installed:" echo " 1. Homebrew to download and install JDK (macOS only)" -echo " 2. Git for cloning the java-tron repository" +echo " 2. Git for cloning github repository" if [[ "$OS" == "Darwin" ]]; then if [[ "$ARCH" == "x86_64" ]]; then echo " 3. OpenJDK 8 (required for x86_64 architecture)" diff --git a/tron_java_env.sh b/tron_java_env.sh index 9a213d09ea..32d8ad0ae8 100755 --- a/tron_java_env.sh +++ b/tron_java_env.sh @@ -1,7 +1,7 @@ #!/bin/bash # TRON Java Environment Configuration -# Generated by install_dependencies.sh on Thu Jan 22 15:27:00 +08 2026 +# Generated by install_dependencies.sh on Thu Jan 22 16:12:18 +08 2026 export JAVA_HOME="/opt/homebrew/opt/openjdk@17" export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" From 26c2c66a049f8679f2bcdd8d35c8085dbc2e3a53 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 16:22:48 +0800 Subject: [PATCH 10/23] merge --- tron_java_env.sh | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100755 tron_java_env.sh diff --git a/tron_java_env.sh b/tron_java_env.sh deleted file mode 100755 index 32d8ad0ae8..0000000000 --- a/tron_java_env.sh +++ /dev/null @@ -1,11 +0,0 @@ - -#!/bin/bash -# TRON Java Environment Configuration -# Generated by install_dependencies.sh on Thu Jan 22 16:12:18 +08 2026 - -export JAVA_HOME="/opt/homebrew/opt/openjdk@17" -export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH" - -echo "Java environment configured:" -echo " JAVA_HOME: $JAVA_HOME" -echo " Java version: $(java -version 2>&1 | head -n 1)" From 42be19604ab542eeec0acfbb256da83c25c5e5a4 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 16:23:22 +0800 Subject: [PATCH 11/23] fix format --- install_dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 3c7292b302..84f58923f5 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -26,7 +26,7 @@ echo " Note: Other platforms may require manual installation if errors occur" echo "" echo ">>> This script will install the following components if not already installed:" echo " 1. Homebrew to download and install JDK (macOS only)" -echo " 2. Git for cloning github repository" +echo " 2. Git for cloning Github repository" if [[ "$OS" == "Darwin" ]]; then if [[ "$ARCH" == "x86_64" ]]; then echo " 3. OpenJDK 8 (required for x86_64 architecture)" From 9bfb5d9f91a0374676a60b7854cc0788ed324a24 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Thu, 22 Jan 2026 18:51:36 +0800 Subject: [PATCH 12/23] update homebrew --- install_dependencies.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 84f58923f5..d45c8aa47c 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -11,7 +11,7 @@ echo "========================================" echo "" echo ">>> Environment Detection" if [[ "$OS" == "Darwin" ]]; then - echo " OS: MacOS $OS" + echo " OS: macOS $OS" elif [[ "$OS" == "Linux" ]]; then echo " OS: $OS" fi @@ -410,8 +410,24 @@ echo "----------------------------------------" install_macos() { if ! command -v brew &> /dev/null; then - echo ">>> Homebrew not found. Installing Homebrew..." - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + echo ">>> Homebrew not found." + echo " Homebrew is required to install Java on macOS." + echo "" + while true; do + read -p "Do you want to install Homebrew? (y/N): " yn + case $yn in + [Yy]* ) + echo ">>> Installing Homebrew..." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + break;; + [Nn]* | "" ) + echo "Homebrew installation cancelled." + echo "Cannot proceed with Java installation without Homebrew on macOS." + echo "Please install Homebrew manually or use alternative Java installation methods." + exit 1;; + * ) echo "Please answer yes (y) or no (n).";; + esac + done # Add Homebrew to PATH for the current session (Apple Silicon vs Intel) if [[ "$ARCH" == "arm64" ]]; then From 351093fe71781af088a3da09500a75e6c905a797 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 11:14:11 +0800 Subject: [PATCH 13/23] put unsupport first --- install_dependencies.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index d45c8aa47c..4c2b4ff80e 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -27,20 +27,29 @@ echo "" echo ">>> This script will install the following components if not already installed:" echo " 1. Homebrew to download and install JDK (macOS only)" echo " 2. Git for cloning Github repository" +echo "" if [[ "$OS" == "Darwin" ]]; then if [[ "$ARCH" == "x86_64" ]]; then echo " 3. OpenJDK 8 (required for x86_64 architecture)" elif [[ "$ARCH" == "arm64" ]]; then echo " 3. OpenJDK 17 (required for arm64 architecture)" + else + echo "Error: Unsupported architecture for macOS: $ARCH" + exit 1 fi elif [[ "$OS" == "Linux" ]]; then if [[ "$ARCH" == "x86_64" ]]; then echo " 3. OpenJDK 8 (required for x86_64 architecture)" elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then echo " 3. OpenJDK 17 (required for arm64/aarch64 architecture)" + else + echo "Error: Unsupported architecture for Linux: $ARCH" + exit 1 fi +else + echo "Error: Unsupported Operating System: $OS" + exit 1 fi -echo "" # Function to ask for user confirmation ask_confirmation() { @@ -140,9 +149,6 @@ if [[ "$OS" == "Darwin" ]]; then elif [[ "$ARCH" == "arm64" ]]; then required_jdk="JDK 17" required_status=1 - else - echo "Error: Unsupported architecture for macOS: $ARCH" - exit 1 fi elif [[ "$OS" == "Linux" ]]; then if [[ "$ARCH" == "x86_64" ]]; then @@ -151,13 +157,7 @@ elif [[ "$OS" == "Linux" ]]; then elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then required_jdk="JDK 17" required_status=1 - else - echo "Error: Unsupported architecture for Linux: $ARCH" - exit 1 fi -else - echo "Error: Unsupported Operating System: $OS" - exit 1 fi # Check if correct JDK version is already installed From 1454f202b2711b340bf0af0087b85f758502e876 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 11:34:33 +0800 Subject: [PATCH 14/23] update env check --- install_dependencies.sh | 46 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 4c2b4ff80e..10b0dd06d4 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -12,10 +12,27 @@ echo "" echo ">>> Environment Detection" if [[ "$OS" == "Darwin" ]]; then echo " OS: macOS $OS" -elif [[ "$OS" == "Linux" ]]; then +else echo " OS: $OS" fi echo " Architecture: $ARCH" + +# Validate OS and architecture support first +if [[ "$OS" != "Darwin" && "$OS" != "Linux" ]]; then + echo "Error: Unsupported OS $OS" + exit 1 +elif [[ "$OS" == "Darwin" ]]; then + if [[ "$ARCH" != "x86_64" && "$ARCH" != "arm64" ]]; then + echo "Error: Unsupported architecture for macOS: $ARCH" + exit 1 + fi +else + if [[ "$ARCH" != "x86_64" && "$ARCH" != "aarch64" && "$ARCH" != "arm64" ]]; then + echo "Error: Unsupported architecture for Linux: $ARCH" + exit 1 + fi +fi + echo "" echo ">>> Tested platforms:" echo " - macOS x86_64 (JDK 8)" @@ -25,31 +42,26 @@ echo " - Linux arm64/aarch64 (generic, including Ubuntu) (JDK 17)" echo " Note: Other platforms may require manual installation if errors occur" echo "" echo ">>> This script will install the following components if not already installed:" -echo " 1. Homebrew to download and install JDK (macOS only)" -echo " 2. Git for cloning Github repository" -echo "" +if [[ "$OS" == "Darwin" ]]; then + echo " 1. Homebrew to download and install JDK (macOS only)" + echo " 2. Git for cloning Github repository" +else + echo " 1. Git for cloning Github repository" +fi if [[ "$OS" == "Darwin" ]]; then if [[ "$ARCH" == "x86_64" ]]; then echo " 3. OpenJDK 8 (required for x86_64 architecture)" - elif [[ "$ARCH" == "arm64" ]]; then - echo " 3. OpenJDK 17 (required for arm64 architecture)" else - echo "Error: Unsupported architecture for macOS: $ARCH" - exit 1 + echo " 3. OpenJDK 17 (required for arm64 architecture)" fi -elif [[ "$OS" == "Linux" ]]; then +else if [[ "$ARCH" == "x86_64" ]]; then - echo " 3. OpenJDK 8 (required for x86_64 architecture)" - elif [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then - echo " 3. OpenJDK 17 (required for arm64/aarch64 architecture)" + echo " 2. OpenJDK 8 (required for x86_64 architecture)" else - echo "Error: Unsupported architecture for Linux: $ARCH" - exit 1 + echo " 2. OpenJDK 17 (required for arm64/aarch64 architecture)" fi -else - echo "Error: Unsupported Operating System: $OS" - exit 1 fi +echo "" # Function to ask for user confirmation ask_confirmation() { From 49a1c3d69b1276733e2bf1b5a3e4043a47ca72f0 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 11:46:56 +0800 Subject: [PATCH 15/23] fix env check --- install_dependencies.sh | 139 ++++++++++++++++++++++++++++++++-------- 1 file changed, 114 insertions(+), 25 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 10b0dd06d4..69938819c7 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -244,12 +244,16 @@ show_java_env_instructions() { local java_bin_path="$2" echo "" - echo " To apply Java environment to your current shell session:" + echo " ✓ Java environment has been applied to this script session." + echo " To apply Java environment to your current terminal session:" echo " source ./tron_java_env.sh" echo "" - echo " Or run this command directly:" + echo " Or run these commands directly:" echo " export JAVA_HOME=\"$java_home\"" echo " export PATH=\"$java_bin_path:\$PATH\"" + echo "" + echo " Note: You may need to open a new terminal or run 'source ./tron_java_env.sh'" + echo " if 'java -version' doesn't work immediately after this script completes." } # Function to get Java paths based on OS and architecture @@ -260,14 +264,36 @@ get_java_paths() { local java_home="" if [[ "$os_type" == "Darwin" ]]; then - # macOS paths + # macOS paths - try to detect actual Homebrew installation if [[ "$jdk_version" == "8" ]]; then - java_home="/usr/local/opt/openjdk@8" + # Try multiple possible paths for JDK 8 + for path in "/usr/local/opt/openjdk@8" "/opt/homebrew/opt/openjdk@8"; do + if [[ -d "$path" ]]; then + java_home="$path" + break + fi + done + # If not found, use brew --prefix to get the correct path + if [[ -z "$java_home" ]] && command -v brew &> /dev/null; then + local brew_prefix=$(brew --prefix openjdk@8 2>/dev/null || echo "") + if [[ -n "$brew_prefix" && -d "$brew_prefix" ]]; then + java_home="$brew_prefix" + fi + fi elif [[ "$jdk_version" == "17" ]]; then - if [[ "$arch" == "arm64" ]]; then - java_home="/opt/homebrew/opt/openjdk@17" - else - java_home="/usr/local/opt/openjdk@17" + # Try multiple possible paths for JDK 17 + for path in "/opt/homebrew/opt/openjdk@17" "/usr/local/opt/openjdk@17"; do + if [[ -d "$path" ]]; then + java_home="$path" + break + fi + done + # If not found, use brew --prefix to get the correct path + if [[ -z "$java_home" ]] && command -v brew &> /dev/null; then + local brew_prefix=$(brew --prefix openjdk@17 2>/dev/null || echo "") + if [[ -n "$brew_prefix" && -d "$brew_prefix" ]]; then + java_home="$brew_prefix" + fi fi fi elif [[ "$os_type" == "Linux" ]]; then @@ -340,6 +366,31 @@ configure_java_environment() { # Use the helper function for macOS java_home=$(get_java_paths "$jdk_version" "$os_type" "$arch") java_bin_path="$java_home/bin" + + # Debug output for macOS + echo " Detected Java path: $java_home" + if [[ ! -d "$java_home" ]]; then + echo " Warning: Java home directory not found at: $java_home" + echo " Attempting to find JDK installation..." + + # Try to find the installation using brew + if command -v brew &> /dev/null; then + local brew_list=$(brew list --formula | grep "openjdk@$jdk_version" || echo "") + if [[ -n "$brew_list" ]]; then + echo " Found Homebrew package: $brew_list" + local brew_prefix=$(brew --prefix openjdk@$jdk_version 2>/dev/null || echo "") + if [[ -n "$brew_prefix" && -d "$brew_prefix" ]]; then + java_home="$brew_prefix" + java_bin_path="$java_home/bin" + echo " Updated Java path to: $java_home" + fi + else + echo " Error: openjdk@$jdk_version not found in Homebrew packages" + echo " Try running: brew list | grep openjdk" + return 1 + fi + fi + fi elif [[ "$os_type" == "Linux" ]]; then # Linux paths - try to find the actual installation if [[ "$jdk_version" == "8" ]]; then @@ -388,22 +439,28 @@ configure_java_environment() { # Create a source script for the user's current shell local env_script="./tron_java_env.sh" - cat > "$env_script" << EOF - + cat > "$env_script" << 'EOF' #!/bin/bash # TRON Java Environment Configuration # Generated by install_dependencies.sh on $(date) export JAVA_HOME="$java_home" -export PATH="$java_bin_path:\$PATH" +export PATH="$java_bin_path:$PATH" echo "Java environment configured:" -echo " JAVA_HOME: \$JAVA_HOME" -echo " Java version: \$(java -version 2>&1 | head -n 1)" +echo " JAVA_HOME: $JAVA_HOME" +echo " Java version: $(java -version 2>&1 | head -n 1)" EOF + # Replace placeholders with actual values + sed -i.bak "s|\$java_home|$java_home|g; s|\$java_bin_path|$java_bin_path|g" "$env_script" + rm -f "$env_script.bak" chmod +x "$env_script" echo "" + echo " Applying Java environment to current shell session..." + # Source the environment script to apply it immediately + source "$env_script" + show_java_env_instructions "$java_home" "$java_bin_path" else @@ -484,13 +541,19 @@ install_macos() { else echo ">>> Installing JDK 8..." fi - brew install openjdk@8 - - # Use unified Java environment configuration - if configure_java_environment "8" "Darwin" "$ARCH"; then - echo "Environment has been updated! Java 8 is now configured." + if brew install openjdk@8; then + echo ">>> JDK 8 installation completed successfully." + + # Use unified Java environment configuration + if configure_java_environment "8" "Darwin" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + fi else - echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + echo "Error: Failed to install JDK 8 via Homebrew." + echo "Please try installing manually with: brew install openjdk@8" + exit 1 fi fi @@ -511,13 +574,19 @@ install_macos() { else echo ">>> Installing JDK 17..." fi - brew install openjdk@17 + if brew install openjdk@17; then + echo ">>> JDK 17 installation completed successfully." - # Use unified Java environment configuration - if configure_java_environment "17" "Darwin" "$ARCH"; then - echo "Environment has been updated! Java 17 is now configured." + # Use unified Java environment configuration + if configure_java_environment "17" "Darwin" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + fi else - echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + echo "Error: Failed to install JDK 17 via Homebrew." + echo "Please try installing manually with: brew install openjdk@17" + exit 1 fi fi @@ -653,9 +722,29 @@ echo "" echo ">>> Verification Commands:" echo " git --version" echo " java -version" +echo "" + +# Verify that Java is actually working +echo ">>> Verifying Java installation..." +if command -v java &> /dev/null; then + echo " Java command found: $(which java)" + if java -version &> /dev/null; then + echo " Java version: $(java -version 2>&1 | head -n 1)" + echo " ✓ Java is working correctly!" + else + echo " ✗ Java command exists but cannot run properly" + echo " Please run: source ./tron_java_env.sh" + fi +else + echo " ✗ Java command not found in PATH" + echo " Please run: source ./tron_java_env.sh" + echo " If that doesn't work, check the Java environment configuration above." +fi + echo "" echo ">>> Troubleshooting:" -echo " - If 'java -version' shows incorrect version, check Configuring Java environment instructions shown above." +echo " - If 'java -version' shows incorrect version, run: source ./tron_java_env.sh" +echo " - For permanent configuration, follow the instructions shown above." echo "" echo "Your development environment is ready for TRON!" echo "" \ No newline at end of file From 1de30ee6b0005702862d02c6df89f1f67512631d Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 11:56:36 +0800 Subject: [PATCH 16/23] optimize evn check --- install_dependencies.sh | 132 +++++++++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 16 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 69938819c7..8dd2aaf56e 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -631,12 +631,54 @@ install_linux() { fi install_first_available() { + local target_version="$1" + shift + local installed_package="" + for pkg in "$@"; do + echo " Attempting to install: $pkg" if $INSTALL_CMD "$pkg"; then - return 0 + installed_package="$pkg" + echo " Successfully installed: $pkg" + break + else + echo " Failed to install: $pkg" fi done - return 1 + + if [[ -n "$installed_package" ]]; then + # Verify what version was actually installed + echo " Verifying installed Java version..." + if command -v java &> /dev/null; then + local actual_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + echo " Installed Java version: $actual_version" + + # Check if the installed version matches what we expected + if [[ "$target_version" == "8" ]]; then + if [[ "$actual_version" =~ ^1\.8\. ]]; then + echo " ✓ JDK 8 installed successfully" + return 0 + else + echo " ✗ Expected JDK 8 but got: $actual_version" + echo " This may happen if JDK 8 is not available in your distribution" + return 2 + fi + elif [[ "$target_version" == "17" ]]; then + if [[ "$actual_version" =~ ^17\. ]]; then + echo " ✓ JDK 17 installed successfully" + return 0 + else + echo " ✗ Expected JDK 17 but got: $actual_version" + return 2 + fi + fi + else + echo " ✗ Java command not found after installation" + return 1 + fi + else + return 1 + fi } if [[ "$ARCH" == "x86_64" ]]; then @@ -657,16 +699,45 @@ install_linux() { echo ">>> Installing JDK 8..." fi if [[ "$PKG_MANAGER" == "apt-get" ]]; then - install_first_available openjdk-8-jdk + if install_first_available "8" openjdk-8-jdk; then + install_result=0 + else + install_result=$? + fi else - install_first_available java-1.8.0-amazon-corretto-devel java-1.8.0-openjdk-devel - fi || { echo "Error: Unable to install JDK 8 on $PKG_MANAGER"; exit 1; } + if install_first_available "8" java-1.8.0-amazon-corretto-devel java-1.8.0-openjdk-devel; then + install_result=0 + else + install_result=$? + fi + fi - # Use unified Java environment configuration - if configure_java_environment "8" "Linux" "$ARCH"; then - echo "Environment has been updated! Java 8 is now configured." + if [[ $install_result -eq 0 ]]; then + # Use unified Java environment configuration + if configure_java_environment "8" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + fi + elif [[ $install_result -eq 2 ]]; then + # Wrong version was installed, but we can still configure it + local actual_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + echo ">>> JDK 8 is not available, but JDK was installed: $actual_version" + + if [[ "$actual_version" =~ ^17\. ]]; then + echo ">>> Configuring environment for the installed JDK 17..." + if configure_java_environment "17" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + fi + else + echo ">>> Configuring environment for the installed Java version..." + echo ">>> You may need to manually configure JAVA_HOME for version: $actual_version" + fi else - echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + echo "Error: Unable to install any JDK on $PKG_MANAGER" + exit 1 fi fi @@ -688,16 +759,45 @@ install_linux() { echo ">>> Installing JDK 17..." fi if [[ "$PKG_MANAGER" == "apt-get" ]]; then - install_first_available openjdk-17-jdk + if install_first_available "17" openjdk-17-jdk; then + install_result=0 + else + install_result=$? + fi else - install_first_available java-17-amazon-corretto-devel java-17-openjdk-devel - fi || { echo "Error: Unable to install JDK 17 on $PKG_MANAGER"; exit 1; } + if install_first_available "17" java-17-amazon-corretto-devel java-17-openjdk-devel; then + install_result=0 + else + install_result=$? + fi + fi - # Use unified Java environment configuration - if configure_java_environment "17" "Linux" "$ARCH"; then - echo "Environment has been updated! Java 17 is now configured." + if [[ $install_result -eq 0 ]]; then + # Use unified Java environment configuration + if configure_java_environment "17" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + fi + elif [[ $install_result -eq 2 ]]; then + # Wrong version was installed, but we can still configure it + local actual_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + echo ">>> JDK 17 is not available, but JDK was installed: $actual_version" + + if [[ "$actual_version" =~ ^1\.8\. ]]; then + echo ">>> Configuring environment for the installed JDK 8..." + if configure_java_environment "8" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + fi + else + echo ">>> Configuring environment for the installed Java version..." + echo ">>> You may need to manually configure JAVA_HOME for version: $actual_version" + fi else - echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + echo "Error: Unable to install any JDK on $PKG_MANAGER" + exit 1 fi fi From 56a4d387e99459a8679e597ddff67a3e90a2b790 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 12:13:03 +0800 Subject: [PATCH 17/23] fix current java path --- install_dependencies.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_dependencies.sh b/install_dependencies.sh index 8dd2aaf56e..c1c1610fb8 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -107,6 +107,10 @@ ask_jdk_confirmation() { echo "" echo "JDK Version Mismatch Detected!" echo " Current version: $current_version" + echo " Current installation path: $(which java 2>/dev/null || echo 'Not found')" + if command -v java &> /dev/null && [[ -n "$JAVA_HOME" ]]; then + echo " Current JAVA_HOME: $JAVA_HOME" + fi echo " Required version for $arch: $required_version" echo " This script will install $required_version alongside your existing installation." echo " Your current Java installation will not be removed." From a1d740c869664d8941e23be08c4ea63c7930eb0e Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 13:56:48 +0800 Subject: [PATCH 18/23] update txt --- install_dependencies.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index c1c1610fb8..00b7c09033 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -849,6 +849,4 @@ echo "" echo ">>> Troubleshooting:" echo " - If 'java -version' shows incorrect version, run: source ./tron_java_env.sh" echo " - For permanent configuration, follow the instructions shown above." -echo "" -echo "Your development environment is ready for TRON!" echo "" \ No newline at end of file From fb3aa6a3168da121f4242db983dc17e37ef659b4 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 14:53:24 +0800 Subject: [PATCH 19/23] delete nohup --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4864dbef4f..0f8b30704b 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,8 @@ Network selection is performed by specifying the appropriate configuration file ### 1. Join the TRON main network Launch a main-network full node with the built-in default configuration: ```bash -nohup java -jar ./build/libs/FullNode.jar & +java -jar ./build/libs/FullNode.jar ``` -* `nohup ... &`: Runs the command in the background and ignores the hangup signal. > For production deployments or long-running Mainnet nodes, please refer to the [JVM Parameter Optimization for FullNode](https://tronprotocol.github.io/documentation-en/using_javatron/installing_javatron/#jvm-parameter-optimization-for-mainnet-fullnode-deployment) guide for the recommended Java command configuration. @@ -132,7 +131,7 @@ Use [TronScan](https://tronscan.org/#/), TRON's official block explorer, to view Utilize the `-c` flag to direct the node to the configuration file corresponding to the desired network. Since Nile TestNet may incorporate features not yet available on the MainNet, it is **strongly advised** to compile the source code following the [Building the Source Code](https://github.com/tron-nile-testnet/nile-testnet/blob/master/README.md#building-the-source-code) instructions for the Nile TestNet. ```bash -nohup java -jar ./build/libs/FullNode.jar -c config-nile.conf & +java -jar ./build/libs/FullNode.jar -c config-nile.conf ``` Nile resources: explorer, faucet, wallet, developer docs, and network statistics at [nileex.io](https://nileex.io/). From 4e93a8da5bcb69d81bab829771549efa06afc5ca Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 16:54:22 +0800 Subject: [PATCH 20/23] fix bug --- install_dependencies.sh | 103 +++++++++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 18 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 00b7c09033..ee4a5c3dec 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -724,20 +724,51 @@ install_linux() { echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." fi elif [[ $install_result -eq 2 ]]; then - # Wrong version was installed, but we can still configure it + # JDK 8 package is installed but default version is different + # Need to switch to JDK 8 using update-alternatives local actual_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) - echo ">>> JDK 8 is not available, but JDK was installed: $actual_version" + echo ">>> JDK 8 package is installed, but system default is: $actual_version" + echo ">>> Switching system default to JDK 8 using update-alternatives..." - if [[ "$actual_version" =~ ^17\. ]]; then - echo ">>> Configuring environment for the installed JDK 17..." - if configure_java_environment "17" "Linux" "$ARCH"; then - echo "Environment has been updated! Java 17 is now configured." + # Try to switch to JDK 8 + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + local jdk8_path="/usr/lib/jvm/java-8-openjdk-amd64" + if [[ -d "$jdk8_path" ]]; then + echo " Found JDK 8 at: $jdk8_path" + # Set JDK 8 as default using update-alternatives + sudo update-alternatives --set java "$jdk8_path/jre/bin/java" 2>/dev/null || \ + sudo update-alternatives --set java "$jdk8_path/bin/java" 2>/dev/null || \ + echo " Note: Could not auto-switch. Please run: sudo update-alternatives --config java" + + sudo update-alternatives --set javac "$jdk8_path/bin/javac" 2>/dev/null || \ + echo " Note: Could not auto-switch javac. Please run: sudo update-alternatives --config javac" + + # Verify the switch + local new_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + if [[ "$new_version" =~ ^1\.8\. ]]; then + echo " ✓ Successfully switched to JDK 8: $new_version" + # Now configure environment for JDK 8 + if configure_java_environment "8" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 8 is now configured." + else + echo "Java 8 is active but environment not configured. You may need to set JAVA_HOME manually." + fi + else + echo " ✗ Auto-switch failed. Current version: $new_version" + echo " Please manually switch to JDK 8:" + echo " sudo update-alternatives --config java" + echo " sudo update-alternatives --config javac" + echo " Then configure environment for JDK 8" + fi else - echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." + echo " ✗ JDK 8 directory not found at expected location: $jdk8_path" + echo " Please manually locate and configure JDK 8" fi else - echo ">>> Configuring environment for the installed Java version..." - echo ">>> You may need to manually configure JAVA_HOME for version: $actual_version" + # For yum/dnf systems + echo " Please manually switch to JDK 8:" + echo " sudo alternatives --config java" + echo " sudo alternatives --config javac" fi else echo "Error: Unable to install any JDK on $PKG_MANAGER" @@ -784,20 +815,56 @@ install_linux() { echo "Java 17 installed but environment not configured. You may need to set JAVA_HOME manually." fi elif [[ $install_result -eq 2 ]]; then - # Wrong version was installed, but we can still configure it + # JDK 17 package is installed but default version is different + # Need to switch to JDK 17 using update-alternatives local actual_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) - echo ">>> JDK 17 is not available, but JDK was installed: $actual_version" + echo ">>> JDK 17 package is installed, but system default is: $actual_version" + echo ">>> Switching system default to JDK 17 using update-alternatives..." - if [[ "$actual_version" =~ ^1\.8\. ]]; then - echo ">>> Configuring environment for the installed JDK 8..." - if configure_java_environment "8" "Linux" "$ARCH"; then - echo "Environment has been updated! Java 8 is now configured." + # Try to switch to JDK 17 + if [[ "$PKG_MANAGER" == "apt-get" ]]; then + local jdk17_path="" + if [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "arm64" ]]; then + jdk17_path="/usr/lib/jvm/java-17-openjdk-arm64" else - echo "Java 8 installed but environment not configured. You may need to set JAVA_HOME manually." + jdk17_path="/usr/lib/jvm/java-17-openjdk-amd64" + fi + + if [[ -d "$jdk17_path" ]]; then + echo " Found JDK 17 at: $jdk17_path" + # Set JDK 17 as default using update-alternatives + sudo update-alternatives --set java "$jdk17_path/bin/java" 2>/dev/null || \ + echo " Note: Could not auto-switch. Please run: sudo update-alternatives --config java" + + sudo update-alternatives --set javac "$jdk17_path/bin/javac" 2>/dev/null || \ + echo " Note: Could not auto-switch javac. Please run: sudo update-alternatives --config javac" + + # Verify the switch + local new_version=$(java -version 2>&1 | head -n 1 | cut -d'"' -f2) + if [[ "$new_version" =~ ^17\. ]]; then + echo " ✓ Successfully switched to JDK 17: $new_version" + # Now configure environment for JDK 17 + if configure_java_environment "17" "Linux" "$ARCH"; then + echo "Environment has been updated! Java 17 is now configured." + else + echo "Java 17 is active but environment not configured. You may need to set JAVA_HOME manually." + fi + else + echo " ✗ Auto-switch failed. Current version: $new_version" + echo " Please manually switch to JDK 17:" + echo " sudo update-alternatives --config java" + echo " sudo update-alternatives --config javac" + echo " Then configure environment for JDK 17" + fi + else + echo " ✗ JDK 17 directory not found at expected location: $jdk17_path" + echo " Please manually locate and configure JDK 17" fi else - echo ">>> Configuring environment for the installed Java version..." - echo ">>> You may need to manually configure JAVA_HOME for version: $actual_version" + # For yum/dnf systems + echo " Please manually switch to JDK 17:" + echo " sudo alternatives --config java" + echo " sudo alternatives --config javac" fi else echo "Error: Unable to install any JDK on $PKG_MANAGER" From b77a50f243e3e8056c0c1a209b9c7567c0788e33 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 17:10:47 +0800 Subject: [PATCH 21/23] fix comments --- install_dependencies.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index ee4a5c3dec..45ecf886a2 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -83,11 +83,11 @@ check_java_version() { # Check if it's JDK 8 (version starts with 1.8) if [[ "$java_version" =~ ^1\.8\. ]]; then - echo " JDK 8 is already installed." + echo " JDK 8 is installed." return 0 # Check if it's JDK 17 (version starts with 17) elif [[ "$java_version" =~ ^17\. ]]; then - echo " JDK 17 is already installed." + echo " JDK 17 is installed." return 1 else echo " Different Java version detected: $java_version" @@ -888,7 +888,7 @@ else fi echo "----------------------------------------" -echo "Installation completed successfully!" +echo "Installation completed!" echo "" echo ">>> Verification Commands:" echo " git --version" @@ -901,7 +901,6 @@ if command -v java &> /dev/null; then echo " Java command found: $(which java)" if java -version &> /dev/null; then echo " Java version: $(java -version 2>&1 | head -n 1)" - echo " ✓ Java is working correctly!" else echo " ✗ Java command exists but cannot run properly" echo " Please run: source ./tron_java_env.sh" From 12aea4cb8068cb85f9a6f00a29992eb7b4265a21 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Tue, 27 Jan 2026 17:22:09 +0800 Subject: [PATCH 22/23] update --- install_dependencies.sh | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 45ecf886a2..7d6751cbe1 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -353,6 +353,25 @@ configure_java_environment() { echo " /usr/lib/jvm/java-1.$jdk_version.0-openjdk (RHEL/CentOS)" fi + # Create tron_java_env.sh even when user skips configuration + echo "" + echo ">>> Creating tron_java_env.sh for manual use later..." + local env_script="./tron_java_env.sh" + cat > "$env_script" << EOF +#!/bin/bash +# TRON Java Environment Configuration +# Generated by install_dependencies.sh on $(date) + +export JAVA_HOME="$expected_java_home" +export PATH="$expected_java_bin_path:\$PATH" + +echo "Java environment configured:" +echo " JAVA_HOME: \$JAVA_HOME" +echo " Java version: \$(java -version 2>&1 | head -n 1)" +EOF + chmod +x "$env_script" + echo " ✓ Created $env_script" + # Show the same application instructions as automatic configuration show_java_env_instructions "$expected_java_home" "$expected_java_bin_path" @@ -443,22 +462,21 @@ configure_java_environment() { # Create a source script for the user's current shell local env_script="./tron_java_env.sh" - cat > "$env_script" << 'EOF' + cat > "$env_script" << EOF #!/bin/bash # TRON Java Environment Configuration # Generated by install_dependencies.sh on $(date) export JAVA_HOME="$java_home" -export PATH="$java_bin_path:$PATH" +export PATH="$java_bin_path:\$PATH" echo "Java environment configured:" -echo " JAVA_HOME: $JAVA_HOME" -echo " Java version: $(java -version 2>&1 | head -n 1)" +echo " JAVA_HOME: \$JAVA_HOME" +echo " Java version: \$(java -version 2>&1 | head -n 1)" EOF - # Replace placeholders with actual values - sed -i.bak "s|\$java_home|$java_home|g; s|\$java_bin_path|$java_bin_path|g" "$env_script" - rm -f "$env_script.bak" chmod +x "$env_script" + echo "" + echo " ✓ Created $env_script" echo "" echo " Applying Java environment to current shell session..." @@ -888,7 +906,7 @@ else fi echo "----------------------------------------" -echo "Installation completed!" +echo "Installation completed successfully!" echo "" echo ">>> Verification Commands:" echo " git --version" @@ -901,6 +919,7 @@ if command -v java &> /dev/null; then echo " Java command found: $(which java)" if java -version &> /dev/null; then echo " Java version: $(java -version 2>&1 | head -n 1)" + echo " ✓ Java is working correctly!" else echo " ✗ Java command exists but cannot run properly" echo " Please run: source ./tron_java_env.sh" @@ -915,4 +934,5 @@ echo "" echo ">>> Troubleshooting:" echo " - If 'java -version' shows incorrect version, run: source ./tron_java_env.sh" echo " - For permanent configuration, follow the instructions shown above." +echo "" echo "" \ No newline at end of file From 046c385b851f661ba221a9a0642ed239ad851505 Mon Sep 17 00:00:00 2001 From: GrapeS Date: Wed, 28 Jan 2026 10:38:37 +0800 Subject: [PATCH 23/23] fix script --- install_dependencies.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/install_dependencies.sh b/install_dependencies.sh index 7d6751cbe1..f72ecf2e19 100755 --- a/install_dependencies.sh +++ b/install_dependencies.sh @@ -787,6 +787,16 @@ install_linux() { echo " Please manually switch to JDK 8:" echo " sudo alternatives --config java" echo " sudo alternatives --config javac" + echo "" + echo " After switching, you can configure the environment." + + # Still create tron_java_env.sh for manual use + if configure_java_environment "8" "Linux" "$ARCH"; then + echo "Environment configuration completed for JDK 8." + else + echo "tron_java_env.sh has been created for manual use." + echo "After switching to JDK 8, run: source ./tron_java_env.sh" + fi fi else echo "Error: Unable to install any JDK on $PKG_MANAGER" @@ -883,6 +893,16 @@ install_linux() { echo " Please manually switch to JDK 17:" echo " sudo alternatives --config java" echo " sudo alternatives --config javac" + echo "" + echo " After switching, you can configure the environment." + + # Still create tron_java_env.sh for manual use + if configure_java_environment "17" "Linux" "$ARCH"; then + echo "Environment configuration completed for JDK 17." + else + echo "tron_java_env.sh has been created for manual use." + echo "After switching to JDK 17, run: source ./tron_java_env.sh" + fi fi else echo "Error: Unable to install any JDK on $PKG_MANAGER" @@ -919,7 +939,6 @@ if command -v java &> /dev/null; then echo " Java command found: $(which java)" if java -version &> /dev/null; then echo " Java version: $(java -version 2>&1 | head -n 1)" - echo " ✓ Java is working correctly!" else echo " ✗ Java command exists but cannot run properly" echo " Please run: source ./tron_java_env.sh"