Mac安装JD-GUI
Mac安装反编译工具步骤如下:
- 打开官网https://java-decompiler.github.io/
- 选择下载mac的安装包
- 解压下载好的压缩包,点击JD-GUI安装
- 有可能会遇到如下错误。
- 请先检查是否安装JDK,通过java -version命令查看是否是1.8版本的jdk
- 如果jdk没问题,那么需要修改安装包文件。
- 点击显示包内容->Contents->MacOs->universalJavaApplicationStub.sh;
- 编辑文件,把universalJavaApplicationStub.sh文件内容替换为如下内容:
-
#!/bin/bash ################################################################################## # # # universalJavaApplicationStub # # # # A BASH based JavaApplicationStub for Java Apps on Mac OS X # # that works with both Apple's and Oracle's plist format. # # # # Inspired by Ian Roberts stackoverflow answer # # at http://stackoverflow.com/a/17546508/1128689 # # # # @author Tobias Fischer # # @url https://github.com/tofi86/universalJavaApplicationStub # # @date 2020-03-19 # # @version 3.0.6 # # # ################################################################################## # # # The MIT License (MIT) # # # # Copyright (c) 2014-2020 Tobias Fischer # # # # Permission is hereby granted, free of charge, to any person obtaining a copy # # of this software and associated documentation files (the "Software"), to deal # # in the Software without restriction, including without limitation the rights # # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # # copies of the Software, and to permit persons to whom the Software is # # furnished to do so, subject to the following conditions: # # # # The above copyright notice and this permission notice shall be included in all # # copies or substantial portions of the Software. # # # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # # SOFTWARE. # # # ################################################################################### function 'stub_logger()' # # A logger which logs to the macOS Console.app using the 'syslog' command # # @param1 the log message # @return void ################################################################################ function stub_logger() {syslog -s -k \Facility com.apple.console \Level Notice \Sender "$(basename "$0")" \Message "[$$][${CFBundleName:-$(basename "$0")}] $1" }# set the directory abspath of the current # shell script with symlinks being resolved ############################################PRG=$0 while [ -h "$PRG" ]; dols=$(ls -ld "$PRG")link=$(expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null)if expr "$link" : '^/' 2> /dev/null >/dev/null; thenPRG="$link"elsePRG="$(dirname "$PRG")/$link"fi done PROGDIR=$(dirname "$PRG") stub_logger "[StubDir] $PROGDIR"# set files and folders ############################################# the absolute path of the app package cd "$PROGDIR"/../../ || exit 11 AppPackageFolder=$(pwd)# the base path of the app package cd .. || exit 12 AppPackageRoot=$(pwd)# set Apple's Java folder AppleJavaFolder="${AppPackageFolder}"/Contents/Resources/Java# set Apple's Resources folder AppleResourcesFolder="${AppPackageFolder}"/Contents/Resources# set Oracle's Java folder OracleJavaFolder="${AppPackageFolder}"/Contents/Java# set Oracle's Resources folder OracleResourcesFolder="${AppPackageFolder}"/Contents/Resources# set path to Info.plist in bundle InfoPlistFile="${AppPackageFolder}"/Contents/Info.plist# set the default JVM Version to a null string JVMVersion="" JVMMaxVersion=""# function 'plist_get()' # # read a specific Plist key with 'PlistBuddy' utility # # @param1 the Plist key with leading colon ':' # @return the value as String or Array ################################################################################ plist_get(){/usr/libexec/PlistBuddy -c "print $1" "${InfoPlistFile}" 2> /dev/null }# function 'plist_get_java()' # # read a specific Plist key with 'PlistBuddy' utility # in the 'Java' or 'JavaX' dictionary (<dict>) # # @param1 the Plist :Java(X):Key with leading colon ':' # @return the value as String or Array ################################################################################ plist_get_java(){plist_get ${JavaKey:-":Java"}$1 }# read Info.plist and extract JVM options ############################################# read the program name from CFBundleName CFBundleName=$(plist_get ':CFBundleName')# read the icon file name CFBundleIconFile=$(plist_get ':CFBundleIconFile')# check Info.plist for Apple style Java keys -> if key :Java is present, parse in apple mode /usr/libexec/PlistBuddy -c "print :Java" "${InfoPlistFile}" > /dev/null 2>&1 exitcode=$? JavaKey=":Java"# if no :Java key is present, check Info.plist for universalJavaApplication style JavaX keys -> if key :JavaX is present, parse in apple mode if [ $exitcode -ne 0 ]; then/usr/libexec/PlistBuddy -c "print :JavaX" "${InfoPlistFile}" > /dev/null 2>&1exitcode=$?JavaKey=":JavaX" fi# read 'Info.plist' file in Apple style if exit code returns 0 (true, ':Java' key is present) if [ $exitcode -eq 0 ]; thenstub_logger "[PlistStyle] Apple"# set Java and Resources folderJavaFolder="${AppleJavaFolder}"ResourcesFolder="${AppleResourcesFolder}"APP_PACKAGE="${AppPackageFolder}"JAVAROOT="${AppleJavaFolder}"USER_HOME="$HOME"# read the Java WorkingDirectoryJVMWorkDir=$(plist_get_java ':WorkingDirectory' | xargs)# set Working Directory based upon PList valueif [[ ! -z ${JVMWorkDir} ]]; thenWorkingDirectory="${JVMWorkDir}"else# AppPackageRoot is the standard WorkingDirectory when the script is startedWorkingDirectory="${AppPackageRoot}"fi# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOMEWorkingDirectory=$(eval echo "${WorkingDirectory}")# read the MainClass nameJVMMainClass="$(plist_get_java ':MainClass')"# read the SplashFile nameJVMSplashFile=$(plist_get_java ':SplashFile')# read the JVM Properties as an array and retain spacesIFS=$'\t\n'JVMOptions=($(xargs -n1 <<<$(plist_get_java ':Properties' | grep " =" | sed 's/^ */-D/g' | sed -E 's/ = (.*)$/="\1"/g')))unset IFS# post processing of the array follows further below...# read the ClassPath in either Array or String styleJVMClassPath_RAW=$(plist_get_java ':ClassPath' | xargs)if [[ $JVMClassPath_RAW == *Array* ]] ; thenJVMClassPath=.$(plist_get_java ':ClassPath' | grep " " | sed 's/^ */:/g' | tr -d '\n' | xargs)elseJVMClassPath=${JVMClassPath_RAW}fi# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOMEJVMClassPath=$(eval echo "${JVMClassPath}")# read the JVM Options in either Array or String styleJVMDefaultOptions_RAW=$(plist_get_java ':VMOptions' | xargs)if [[ $JVMDefaultOptions_RAW == *Array* ]] ; thenJVMDefaultOptions=$(plist_get_java ':VMOptions' | grep " " | sed 's/^ */ /g' | tr -d '\n' | xargs)elseJVMDefaultOptions=${JVMDefaultOptions_RAW}fi# read StartOnMainThread and add as -XstartOnFirstThreadJVMStartOnMainThread=$(plist_get_java ':StartOnMainThread')if [ "${JVMStartOnMainThread}" == "true" ]; thenJVMDefaultOptions+=" -XstartOnFirstThread"fi# read the JVM Arguments in either Array or String style (#76) and retain spacesIFS=$'\t\n'MainArgs_RAW=$(plist_get_java ':Arguments' | xargs)if [[ $MainArgs_RAW == *Array* ]] ; thenMainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments' | tr -d '\n' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/ */ /g')))elseMainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments')))fiunset IFS# post processing of the array follows further below...# read the Java version we want to findJVMVersion=$(plist_get_java ':JVMVersion' | xargs)# post processing of the version string follows below...# read 'Info.plist' file in Oracle style elsestub_logger "[PlistStyle] Oracle"# set Working Directory and Java and Resources folderJavaFolder="${OracleJavaFolder}"ResourcesFolder="${OracleResourcesFolder}"WorkingDirectory="${OracleJavaFolder}"APP_ROOT="${AppPackageFolder}"# read the MainClass nameJVMMainClass="$(plist_get ':JVMMainClassName')"# read the SplashFile nameJVMSplashFile=$(plist_get ':JVMSplashFile')# read the JVM Options as an array and retain spacesIFS=$'\t\n'JVMOptions=($(plist_get ':JVMOptions' | grep " " | sed 's/^ *//g'))unset IFS# post processing of the array follows further below...# read the ClassPath in either Array or String styleJVMClassPath_RAW=$(plist_get ':JVMClassPath')if [[ $JVMClassPath_RAW == *Array* ]] ; thenJVMClassPath=.$(plist_get ':JVMClassPath' | grep " " | sed 's/^ */:/g' | tr -d '\n' | xargs)# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOMEJVMClassPath=$(eval echo "${JVMClassPath}")elif [[ ! -z ${JVMClassPath_RAW} ]] ; thenJVMClassPath=${JVMClassPath_RAW}# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOMEJVMClassPath=$(eval echo "${JVMClassPath}")else#default: fallback to OracleJavaFolderJVMClassPath="${JavaFolder}/*"# Do NOT expand the default 'AppName.app/Contents/Java/*' classpath (#42)fi# read the JVM Default OptionsJVMDefaultOptions=$(plist_get ':JVMDefaultOptions' | grep -o " \-.*" | tr -d '\n' | xargs)# read the Main Arguments from JVMArguments key as an array and retain spaces (see #46 for naming details)IFS=$'\t\n'MainArgs=($(xargs -n1 <<<$(plist_get ':JVMArguments' | tr -d '\n' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/ */ /g')))unset IFS# post processing of the array follows further below...# read the Java version we want to findJVMVersion=$(plist_get ':JVMVersion' | xargs)# post processing of the version string follows below... fi# (#75) check for undefined icons or icon names without .icns extension and prepare # an osascript statement for those cases when the icon can be shown in the dialog DialogWithIcon="" if [ ! -z ${CFBundleIconFile} ]; thenif [[ ${CFBundleIconFile} == *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}" ]] ; thenDialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"elif [[ ${CFBundleIconFile} != *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}.icns" ]] ; thenCFBundleIconFile+=".icns"DialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"fi fi# JVMVersion: post processing and optional splitting if [[ ${JVMVersion} == *";"* ]]; thenminMaxArray=(${JVMVersion//;/ })JVMVersion=${minMaxArray[0]//+}JVMMaxVersion=${minMaxArray[1]//+} fi stub_logger "[JavaRequirement] JVM minimum version: ${JVMVersion}" stub_logger "[JavaRequirement] JVM maximum version: ${JVMMaxVersion}"# MainArgs: replace occurences of $APP_ROOT with its content MainArgsArr=() for i in "${MainArgs[@]}" doMainArgsArr+=("$(eval echo "$i")") done# JVMOptions: replace occurences of $APP_ROOT with its content JVMOptionsArr=() for i in "${JVMOptions[@]}" doJVMOptionsArr+=("$(eval echo "$i")") done# internationalized messages ############################################LANG=$(defaults read -g AppleLocale) stub_logger "[Language] $LANG"# French localization if [[ $LANG == fr* ]] ; thenMSG_ERROR_LAUNCHING="ERREUR au lancement de '${CFBundleName}'."MSG_MISSING_MAINCLASS="'MainClass' n'est pas spécifié.\nL'application Java ne peut pas être lancée."MSG_JVMVERSION_REQ_INVALID="La syntaxe de la version de Java demandée est invalide: %s\nVeuillez contacter le développeur de l'application."MSG_NO_SUITABLE_JAVA="La version de Java installée sur votre système ne convient pas.\nCe programme nécessite Java %s"MSG_JAVA_VERSION_OR_LATER="ou ultérieur"MSG_JAVA_VERSION_LATEST="(dernière mise à jour)"MSG_JAVA_VERSION_MAX="à %s"MSG_NO_SUITABLE_JAVA_CHECK="Merci de bien vouloir installer la version de Java requise."MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."MSG_LATER="Plus tard"MSG_VISIT_JAVA_DOT_COM="Java by Oracle"MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"# German localization elif [[ $LANG == de* ]] ; thenMSG_ERROR_LAUNCHING="FEHLER beim Starten von '${CFBundleName}'."MSG_MISSING_MAINCLASS="Die 'MainClass' ist nicht spezifiziert!\nDie Java-Anwendung kann nicht gestartet werden!"MSG_JVMVERSION_REQ_INVALID="Die Syntax der angeforderten Java-Version ist ungültig: %s\nBitte kontaktieren Sie den Entwickler der App."MSG_NO_SUITABLE_JAVA="Es wurde keine passende Java-Version auf Ihrem System gefunden!\nDieses Programm benötigt Java %s"MSG_JAVA_VERSION_OR_LATER="oder neuer"MSG_JAVA_VERSION_LATEST="(neuste Unterversion)"MSG_JAVA_VERSION_MAX="bis %s"MSG_NO_SUITABLE_JAVA_CHECK="Stellen Sie sicher, dass die angeforderte Java-Version installiert ist."MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."MSG_LATER="Später"MSG_VISIT_JAVA_DOT_COM="Java von Oracle"MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"# Simplifyed Chinese localization elif [[ $LANG == zh* ]] ; thenMSG_ERROR_LAUNCHING="无法启动 '${CFBundleName}'."MSG_MISSING_MAINCLASS="没有指定 'MainClass'!\nJava程序无法启动!"MSG_JVMVERSION_REQ_INVALID="Java版本参数语法错误: %s\n请联系该应用的开发者。"MSG_NO_SUITABLE_JAVA="没有在系统中找到合适的Java版本!\n必须安装Java %s才能够使用该程序!"MSG_JAVA_VERSION_OR_LATER="及以上版本"MSG_JAVA_VERSION_LATEST="(最新版本)"MSG_JAVA_VERSION_MAX="最高为 %s"MSG_NO_SUITABLE_JAVA_CHECK="请确保系统中安装了所需的Java版本"MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"MSG_LATER="稍后"MSG_VISIT_JAVA_DOT_COM="Java by Oracle"MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"# English default localization elseMSG_ERROR_LAUNCHING="ERROR launching '${CFBundleName}'."MSG_MISSING_MAINCLASS="'MainClass' isn't specified!\nJava application cannot be started!"MSG_JVMVERSION_REQ_INVALID="The syntax of the required Java version is invalid: %s\nPlease contact the App developer."MSG_NO_SUITABLE_JAVA="No suitable Java version found on your system!\nThis program requires Java %s"MSG_JAVA_VERSION_OR_LATER="or later"MSG_JAVA_VERSION_LATEST="(latest update)"MSG_JAVA_VERSION_MAX="up to %s"MSG_NO_SUITABLE_JAVA_CHECK="Make sure you install the required Java version."MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."MSG_LATER="Later"MSG_VISIT_JAVA_DOT_COM="Java by Oracle"MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK" fi# function 'get_java_version_from_cmd()' # # returns Java version string from 'java -version' command # works for both old (1.8) and new (9) version schema # # @param1 path to a java JVM executable # @return the Java version number as displayed in 'java -version' command ################################################################################ function get_java_version_from_cmd() {# second sed command strips " and -ea from the version stringecho $("$1" -version 2>&1 | awk '/version/{print $3}' | sed -E 's/"//g;s/-ea//g') }# function 'extract_java_major_version()' # # extract Java major version from a version string # # @param1 a Java version number ('1.8.0_45') or requirement string ('1.8+') # @return the major version (e.g. '7', '8' or '9', etc.) ################################################################################ function extract_java_major_version() {echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)?[+*]?$/\1/') }# function 'get_comparable_java_version()' # # return comparable version for a Java version number or requirement string # # @param1 a Java version number ('1.8.0_45') or requirement string ('1.8+') # @return an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013') ################################################################################ function get_comparable_java_version() {# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')# splitting at '.' into an arraylocal arr=( ${cleaned//./ } )# echo a string with left padded version numbersecho "$(printf '%02s' ${arr[0]})$(printf '%03s' ${arr[1]})$(printf '%03s' ${arr[2]})" }# function 'is_valid_requirement_pattern()' # # check whether the Java requirement is a valid requirement pattern # # supported requirements are for example: # - 1.6 requires Java 6 (any update) [1.6, 1.6.0_45, 1.6.0_88] # - 1.6* requires Java 6 (any update) [1.6, 1.6.0_45, 1.6.0_88] # - 1.6+ requires Java 6 or higher [1.6, 1.6.0_45, 1.8, 9, etc.] # - 1.6.0 requires Java 6 (any update) [1.6, 1.6.0_45, 1.6.0_88] # - 1.6.0_45 requires Java 6u45 [1.6.0_45] # - 1.6.0_45+ requires Java 6u45 or higher [1.6.0_45, 1.6.0_88, 1.8, etc.] # - 9 requires Java 9 (any update) [9.0.*, 9.1, 9.3, etc.] # - 9* requires Java 9 (any update) [9.0.*, 9.1, 9.3, etc.] # - 9+ requires Java 9 or higher [9.0, 9.1, 10, etc.] # - 9.1 requires Java 9.1 (any update) [9.1.*, 9.1.2, 9.1.13, etc.] # - 9.1* requires Java 9.1 (any update) [9.1.*, 9.1.2, 9.1.13, etc.] # - 9.1+ requires Java 9.1 or higher [9.1, 9.2, 10, etc.] # - 9.1.3 requires Java 9.1.3 [9.1.3] # - 9.1.3* requires Java 9.1.3 (any update) [9.1.3] # - 9.1.3+ requires Java 9.1.3 or higher [9.1.3, 9.1.4, 9.2.*, 10, etc.] # - 10-ea requires Java 10 (early access release) # # unsupported requirement patterns are for example: # - 1.2, 1.3, 1.9 Java 2, 3 are not supported # - 1.9 Java 9 introduced a new versioning scheme # - 6u45 known versioning syntax, but unsupported # - 9-ea*, 9-ea+ early access releases paired with */+ # - 9., 9.*, 9.+ version ending with a . # - 9.1., 9.1.*, 9.1.+ version ending with a . # - 9.3.5.6 4 part version number is unsupported # # @param1 a Java requirement string ('1.8+') # @return boolean exit code: 0 (is valid), 1 (is not valid) ################################################################################ function is_valid_requirement_pattern() {local java_req=$1java8pattern='1\.[4-8](\.[0-9]+)?(\.0_[0-9]+)?[*+]?'java9pattern='(9|1[0-9])(-ea|[*+]|(\.[0-9]+){1,2}[*+]?)?'# test matches either old Java versioning scheme (up to 1.8) or new scheme (starting with 9)if [[ ${java_req} =~ ^(${java8pattern}|${java9pattern})$ ]]; thenreturn 0elsereturn 1fi }# determine which JVM to use ############################################# default Apple JRE plugin path (< 1.6) apple_jre_plugin="/Library/Java/Home/bin/java" apple_jre_version=$(get_java_version_from_cmd "${apple_jre_plugin}") # default Oracle JRE plugin path (>= 1.7) oracle_jre_plugin="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" oracle_jre_version=$(get_java_version_from_cmd "${oracle_jre_plugin}")# first check system variable "$JAVA_HOME" -> has precedence over any other System JVM stub_logger '[JavaSearch] Checking for $JAVA_HOME ...' if [ -n "$JAVA_HOME" ] ; thenstub_logger "[JavaSearch] ... found JAVA_HOME with value $JAVA_HOME"# PR 26: Allow specifying "$JAVA_HOME" relative to "$AppPackageFolder"# which allows for bundling a custom version of Java inside your app!if [[ $JAVA_HOME == /* ]] ; then# if "$JAVA_HOME" starts with a Slash it's an absolute pathJAVACMD="$JAVA_HOME/bin/java"else# otherwise it's a relative path to "$AppPackageFolder"JAVACMD="$AppPackageFolder/$JAVA_HOME/bin/java"fiJAVACMD_version=$(get_comparable_java_version $(get_java_version_from_cmd "${JAVACMD}")) elsestub_logger "[JavaSearch] ... didn't found JAVA_HOME" fi# check for any other or a specific Java version # also if $JAVA_HOME exists but isn't executable if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; thenstub_logger "[JavaSearch] Checking for JavaVirtualMachines on the system ..."# reset variablesJAVACMD=""JAVACMD_version=""# first check whether JVMVersion string is a valid requirement stringif [ ! -z "${JVMVersion}" ] && ! is_valid_requirement_pattern ${JVMVersion} ; thenMSG_JVMVERSION_REQ_INVALID_EXPANDED=$(printf "${MSG_JVMVERSION_REQ_INVALID}" "${JVMVersion}")# log exit causestub_logger "[EXIT 4] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"# display error message with AppleScriptosascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"# exit with errorexit 4fi# then check whether JVMMaxVersion string is a valid requirement stringif [ ! -z "${JVMMaxVersion}" ] && ! is_valid_requirement_pattern ${JVMMaxVersion} ; thenMSG_JVMVERSION_REQ_INVALID_EXPANDED=$(printf "${MSG_JVMVERSION_REQ_INVALID}" "${JVMMaxVersion}")# log exit causestub_logger "[EXIT 5] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"# display error message with AppleScriptosascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"# exit with errorexit 5fi# find installed JavaVirtualMachines (JDK + JRE)allJVMs=()# read JDK's from '/usr/libexec/java_home -V' commandwhile read -r line; doversion=$(echo $line | awk -F $',' '{print $1;}')path=$(echo $line | awk -F $'" ' '{print $2;}')path+="/bin/java"allJVMs+=("$version:$path")done < <(/usr/libexec/java_home -V 2>&1 | grep '^[[:space:]]')# unset while loop variablesunset version path# add Apple JRE if availableif [ -x "${apple_jre_plugin}" ] ; thenallJVMs+=("$apple_jre_version:$apple_jre_plugin")fi# add Oracle JRE if availableif [ -x "${oracle_jre_plugin}" ] ; thenallJVMs+=("$oracle_jre_version:$oracle_jre_plugin")fi# debug outputfor i in "${allJVMs[@]}"dostub_logger "[JavaSearch] ... found JVM: $i"done# determine JVMs matching the min/max version requirementminC=$(get_comparable_java_version ${JVMVersion})maxC=$(get_comparable_java_version ${JVMMaxVersion})matchingJVMs=()for i in "${allJVMs[@]}"do# split JVM string at ':' delimiter to retain spaces in $path substringIFS=: arr=($i) ; unset IFS# [0] JVM version numberver=${arr[0]}# comparable JVM version numbercomp=$(get_comparable_java_version $ver)# [1] JVM pathpath="${arr[1]}"# construct string item for adding to the "matchingJVMs" arrayitem="$comp:$ver:$path"# pre-requisite: current version number needs to be greater than min version numberif [ "$comp" -ge "$minC" ] ; then# perform max version checks if max version requirement is presentif [ ! -z ${JVMMaxVersion} ] ; then# max version requirement ends with '*' modifierif [[ ${JVMMaxVersion} == *\* ]] ; then# use the '*' modifier from the max version string as wildcard for a 'starts with' comparison# and check whether the current version number starts with the max version wildcard stringif [[ ${ver} == ${JVMMaxVersion} ]]; thenmatchingJVMs+=("$item")# or whether the current comparable version is lower than the comparable max versionelif [ "$comp" -le "$maxC" ] ; thenmatchingJVMs+=("$item")fi# max version requirement ends with '+' modifier -> always add this version if it's greater than $min# because a max requirement with + modifier doesn't make senseelif [[ ${JVMMaxVersion} == *+ ]] ; thenmatchingJVMs+=("$item")# matches 6 zeros at the end of the max version string (e.g. for 1.8, 9)# -> then the max version string should be treated like with a '*' modifier at the end#elif [[ ${maxC} =~ ^[0-9]{2}0{6}$ ]] && [ "$comp" -le $(( ${maxC#0} + 999 )) ] ; then# matchingJVMs+=("$item")# matches 3 zeros at the end of the max version string (e.g. for 9.1, 10.3)# -> then the max version string should be treated like with a '*' modifier at the end#elif [[ ${maxC} =~ ^[0-9]{5}0{3}$ ]] && [ "$comp" -le "${maxC}" ] ; then# matchingJVMs+=("$item")# matches standard requirements without modifierelif [ "$comp" -le "$maxC" ]; thenmatchingJVMs+=("$item")fi# no max version requirement:# min version requirement ends with '+' modifier# -> always add the current version because it's greater than $minelif [[ ${JVMVersion} == *+ ]] ; thenmatchingJVMs+=("$item")# min version requirement ends with '*' modifier# -> use the '*' modifier from the min version string as wildcard for a 'starts with' comparison# and check whether the current version number starts with the min version wildcard stringelif [[ ${JVMVersion} == *\* ]] ; thenif [[ ${ver} == ${JVMVersion} ]] ; thenmatchingJVMs+=("$item")fi# compare the min version against the current version with an additional * wildcard for a 'starts with' comparison# -> e.g. add 1.8.0_44 when the requirement is 1.8elif [[ ${ver} == ${JVMVersion}* ]] ; thenmatchingJVMs+=("$item")fifidone# unset for loop variablesunset arr ver comp path item# debug outputfor i in "${matchingJVMs[@]}"dostub_logger "[JavaSearch] ... ... matches all requirements: $i"done# sort the matching JavaVirtualMachines by version number# https://stackoverflow.com/a/11789688/1128689IFS=$'\n' matchingJVMs=($(sort -nr <<<"${matchingJVMs[*]}"))unset IFS# get the highest matching JVMfor ((i = 0; i < ${#matchingJVMs[@]}; i++));do# split JVM string at ':' delimiter to retain spaces in $path substringIFS=: arr=(${matchingJVMs[$i]}) ; unset IFS# [0] comparable JVM version numbercomp=${arr[0]}# [1] JVM version numberver=${arr[1]}# [2] JVM pathpath="${arr[2]}"# use current value as JAVACMD if it's executableif [ -x "$path" ] ; thenJAVACMD="$path"JAVACMD_version=$compbreakfidone# unset for loop variablesunset arr comp ver path fi# log the Java Command and the extracted version number stub_logger "[JavaCommand] '$JAVACMD'" stub_logger "[JavaVersion] $(get_java_version_from_cmd "${JAVACMD}")${JAVACMD_version:+ / $JAVACMD_version}"if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then# different error messages when a specific JVM was requiredif [ ! -z "${JVMVersion}" ] ; then# display human readable java version (#28)java_version_hr=$(echo ${JVMVersion} | sed -E 's/^1\.([0-9+*]+)$/ \1/g' | sed "s/+/ ${MSG_JAVA_VERSION_OR_LATER}/;s/*/ ${MSG_JAVA_VERSION_LATEST}/")MSG_NO_SUITABLE_JAVA_EXPANDED=$(printf "${MSG_NO_SUITABLE_JAVA}" "${java_version_hr}").if [ ! -z "${JVMMaxVersion}" ] ; thenjava_version_hr=$(extract_java_major_version ${JVMVersion})java_version_max_hr=$(echo ${JVMMaxVersion} | sed -E 's/^1\.([0-9+*]+)$/ \1/g' | sed "s/+//;s/*/ ${MSG_JAVA_VERSION_LATEST}/")MSG_NO_SUITABLE_JAVA_EXPANDED="$(printf "${MSG_NO_SUITABLE_JAVA}" "${java_version_hr}") $(printf "${MSG_JAVA_VERSION_MAX}" "${java_version_max_hr}")"fi# log exit causestub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"# display error message with AppleScriptosascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \-e "set response to button returned of the result" \-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""# exit with errorexit 3else# log exit causestub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"# display error message with AppleScriptosascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \-e "set response to button returned of the result" \-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""# exit with errorexit 1fi fi# MainClass check ############################################if [ -z "${JVMMainClass}" ]; then# log exit causestub_logger "[EXIT 2] ${MSG_MISSING_MAINCLASS}"# display error message with AppleScriptosascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_MISSING_MAINCLASS}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"# exit with errorexit 2 fi# execute $JAVACMD and do some preparation ############################################# enable drag&drop to the dock icon export CFProcessPath="$0"# remove Apples ProcessSerialNumber from passthru arguments (#39) if [[ "$*" == -psn* ]] ; thenArgsPassthru=() elseArgsPassthru=("$@") fi# change to Working Directory based upon Apple/Oracle Plist info cd "${WorkingDirectory}" || exit 13 stub_logger "[WorkingDirectory] ${WorkingDirectory}"# execute Java and set # - classpath # - splash image # - dock icon # - app name # - JVM options / properties (-D) # - JVM default options (-X) # - main class # - main class arguments # - passthrough arguments from Terminal or Drag'n'Drop to Finder icon stub_logger "[Exec] \"$JAVACMD\" -cp \"${JVMClassPath}\" -splash:\"${ResourcesFolder}/${JVMSplashFile}\" -Xdock:icon=\"${ResourcesFolder}/${CFBundleIconFile}\" -Xdock:name=\"${CFBundleName}\" ${JVMOptionsArr:+$(printf "'%s' " "${JVMOptionsArr[@]}") }${JVMDefaultOptions:+$JVMDefaultOptions }${JVMMainClass}${MainArgsArr:+ $(printf "'%s' " "${MainArgsArr[@]}")}${ArgsPassthru:+ $(printf "'%s' " "${ArgsPassthru[@]}")}" exec "${JAVACMD}" \-cp "${JVMClassPath}" \-splash:"${ResourcesFolder}/${JVMSplashFile}" \-Xdock:icon="${ResourcesFolder}/${CFBundleIconFile}" \-Xdock:name="${CFBundleName}" \${JVMOptionsArr:+"${JVMOptionsArr[@]}" }\${JVMDefaultOptions:+$JVMDefaultOptions }\"${JVMMainClass}"\${MainArgsArr:+ "${MainArgsArr[@]}"}\${ArgsPassthru:+ "${ArgsPassthru[@]}"}
- 保存,关闭,再次点击JD-GUI便可以顺利打开。
- 最后我们可以把这个应用程序拖到启动台,这样以后需要的时候就可以打开了。
相关文章:

Mac安装JD-GUI
Mac安装反编译工具步骤如下: 打开官网https://java-decompiler.github.io/ 选择下载mac的安装包解压下载好的压缩包,点击JD-GUI安装 有可能会遇到如下错误。请先检查是否安装JDK,通过java -version命令查看是否是1.8版本的jdk如果jdk没问题&…...

Jenkins 配置 Git Parameter 四
Jenkins 配置 Git Parameter 四 一、开启 项目参数设置 勾选 This project is parameterised 二、添加 Git Parameter 如果此处不显示 Git Parameter 说明 Jenkins 还没有安装 Git Parameter plugin 插件,请先安装插件 Jenkins 安装插件 三、设置基本参数 点击…...

【AI】Docker中快速部署Ollama并安装DeepSeek-R1模型: 一步步指南
【AI】Docker中快速部署Ollama并安装DeepSeek-R1模型: 一步步指南 一、前言 为了确保在 Docker 环境中顺利安装并高效运行 Ollama 以及 DeepSeek 离线模型,本文将详细介绍整个过程,涵盖从基础安装到优化配置等各个方面。通过对关键参数和配置的深入理解…...
Python 自然语言处理(NLP)和文本挖掘的常规操作过程
Python 自然语言处理(NLP)和文本挖掘 自然语言处理(NLP)和文本挖掘是数据科学中的重要领域,涉及对文本数据的分析和处理。Python 提供了丰富的库和工具,用于执行各种 NLP 和文本挖掘任务。以下是一些常见的…...
传统数组 vs vector和list
传统的数组: int arr[10]; 传统的数组有以下的缺点: 1)长度不可修改 2)内存分配 局部数组:把数组定在函数内, 数组便是局部变量,故会被分配在栈上 但栈的大小是有限制的 ,故其在内存中不能超…...

CRMEB 多商户版v3.0.1源码全开源+PC端+Uniapp前端+搭建教程
一.介绍 crmeb多商户是一套B2B2C商家入驻模式的平台多商户商城系统,系统支持平台自营、联营、招商等多种运营模式,可满足企业新零售、批发、分销、预售、O2O、多店、商铺入驻等各种业务需求。 后端全开源、uniapp多端可编译! 二、搭建教程…...

【ESP32】ESP-IDF开发 | WiFi开发 | HTTPS服务器 + 搭建例程
1. 简介 1.1 HTTPS HTTPS(HyperText Transfer Protocol over Secure Socket Layer),全称安全套接字层超文本传输协议,一般理解为HTTPSSL/TLS,通过SSL证书来验证服务器的身份,并为浏览器和服务器之间的通信…...
Vue2 中使用 UniApp 时,生命周期钩子函数总结
在 Vue2 中使用 UniApp 时,生命周期钩子函数是一个重要的概念。它允许开发者在特定的时间点运行代码,管理组件的生命周期。以下是 Vue2 中 UniApp 常用的生命周期钩子函数总结: 1. beforeCreate 说明: 组件实例刚被创建,此时数据…...
如何在 Vue 3 中使用 Vue Router 和 Vuex
在 Vue 3 中使用 Vue Router 1. 安装 Vue Router 在项目根目录下,通过 npm 或 yarn 安装 Vue Router 4(适用于 Vue 3): npm install vue-router4 # 或者使用 yarn yarn add vue-router42. 创建路由配置文件 在 src 目录下创建…...

Fiori APP配置中的Semantic object 小bug
在配置自开发程序的Fiori Tile时,需要填入Semantic Object。正常来说,是需要通过事务代码/N/UI2/SEMOBJ来提前新建的。 但是在S4 2022中,似乎存在一个bug,即无需新建也能输入自定义的Semantic Object。 如下,当我们任…...

【触想智能】工业显示器和普通显示器的区别以及工业显示器的主要应用领域分析
在现代工业中,工业显示器被广泛应用于各种场景,从监控系统到生产控制,它们在实时数据显示、操作界面和信息传递方面发挥着重要作用。与普通显示器相比,工业显示器在耐用性、可靠性和适应特殊环境的能力上有着显著的差异。 触想工业…...

BPMN.js 与 DeepSeek 集成:打造个性化 Web 培训项目的秘诀
在数字化时代,Web培训项目的需求日益增长,特别是对于程序员群体,他们寻求高效、灵活的方式来提升自己的技能。本文将深入探讨如何评估BPMN.js与DeepSeek集成方案,以满足开发Web培训项目的需求。 BPMN.js 的优势 BPMN.js是一个专…...
第二月:学习 NumPy、Pandas 和 Matplotlib 是数据分析和科学计算的基础
以下是一个为期 **1 个月(30 天)**的详细学习计划,精确到每天的学习内容和练习作业,帮助你系统地掌握 NumPy、Pandas 和 Matplotlib 的核心功能。 第 1 周:NumPy 基础 Day 1:NumPy 简介与数组创建 学习内…...

安全测试|SSRF请求伪造
前言 SSRF漏洞是一种在未能获取服务器权限时,利用服务器漏洞,由攻击者构造请求,服务器端发起请求的安全漏洞,攻击者可以利用该漏洞诱使服务器端应用程序向攻击者选择的任意域发出HTTP请求。 很多Web应用都提供了从其他的服务器上…...
Flink提交pyflink任务
1.官方文档: flink1.14:https://nightlies.apache.org/flink/flink-docs-release-1.14/docs/deployment/cli/#submitting-pyflink-jobs flink1.18:https://nightlies.apache.org/flink/flink-docs-release-1.18/docs/deployment/cli/#submitting-pyflink-jobs 2.提…...
对称算法模式之CTR
Note 计数器模式,通过加密递增计数器生成密钥流,后密钥流与明文分组异或得密文分组可并行性进行加密或者解密,性能较高明文可以是任意长度,不需要填充可以直接加密或解密指定块,块与块间不具有依赖关系 参数说明 任…...

Map 和 Set
目录 一、搜索 概念: 模型: 二、Map 编辑 1.Map 实例化: 2. Map的常见方法: 3.Map的常见方法演示: 1. put(K key, V value):添加键值对 3. containsKey(Object key):检查键是否存在 4.…...

STOMP协议
引用:https://blog.csdn.net/print_helloword/article/details/142597122 什么是STOMP协议 STOMP (simple text oriented messaging protocol): 一种简单的,基于文本的消息传输协议,,,最初是为了解决在消息队列中&am…...

手动埋点的demo
上代码 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>埋点示例</title> </head><b…...

大模型开发实战篇5:多模态--文生图模型API
大模型文生图是一种基于人工智能大模型的技术,能够将自然语言文本描述转化为对应的图像。目前非常火的AI大模型赛道,有很多公司在此赛道竞争。详情可看这篇文章。 今天我们来看下如何调用WebAPI来实现文生图功能。我们一般都会将OpenAI的接口࿰…...

微软PowerBI考试 PL300-选择 Power BI 模型框架【附练习数据】
微软PowerBI考试 PL300-选择 Power BI 模型框架 20 多年来,Microsoft 持续对企业商业智能 (BI) 进行大量投资。 Azure Analysis Services (AAS) 和 SQL Server Analysis Services (SSAS) 基于无数企业使用的成熟的 BI 数据建模技术。 同样的技术也是 Power BI 数据…...
【Linux】C语言执行shell指令
在C语言中执行Shell指令 在C语言中,有几种方法可以执行Shell指令: 1. 使用system()函数 这是最简单的方法,包含在stdlib.h头文件中: #include <stdlib.h>int main() {system("ls -l"); // 执行ls -l命令retu…...
【磁盘】每天掌握一个Linux命令 - iostat
目录 【磁盘】每天掌握一个Linux命令 - iostat工具概述安装方式核心功能基础用法进阶操作实战案例面试题场景生产场景 注意事项 【磁盘】每天掌握一个Linux命令 - iostat 工具概述 iostat(I/O Statistics)是Linux系统下用于监视系统输入输出设备和CPU使…...
大语言模型如何处理长文本?常用文本分割技术详解
为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...

视频字幕质量评估的大规模细粒度基准
大家读完觉得有帮助记得关注和点赞!!! 摘要 视频字幕在文本到视频生成任务中起着至关重要的作用,因为它们的质量直接影响所生成视频的语义连贯性和视觉保真度。尽管大型视觉-语言模型(VLMs)在字幕生成方面…...
关于 WASM:1. WASM 基础原理
一、WASM 简介 1.1 WebAssembly 是什么? WebAssembly(WASM) 是一种能在现代浏览器中高效运行的二进制指令格式,它不是传统的编程语言,而是一种 低级字节码格式,可由高级语言(如 C、C、Rust&am…...

k8s业务程序联调工具-KtConnect
概述 原理 工具作用是建立了一个从本地到集群的单向VPN,根据VPN原理,打通两个内网必然需要借助一个公共中继节点,ktconnect工具巧妙的利用k8s原生的portforward能力,简化了建立连接的过程,apiserver间接起到了中继节…...
SQL慢可能是触发了ring buffer
简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...

MySQL 知识小结(一)
一、my.cnf配置详解 我们知道安装MySQL有两种方式来安装咱们的MySQL数据库,分别是二进制安装编译数据库或者使用三方yum来进行安装,第三方yum的安装相对于二进制压缩包的安装更快捷,但是文件存放起来数据比较冗余,用二进制能够更好管理咱们M…...
从面试角度回答Android中ContentProvider启动原理
Android中ContentProvider原理的面试角度解析,分为已启动和未启动两种场景: 一、ContentProvider已启动的情况 1. 核心流程 触发条件:当其他组件(如Activity、Service)通过ContentR…...