【JD-GUI】MacOS 中使用Java反编译工具JD-GUI

希望文章能给到你启发和灵感~
如果觉得文章对你有帮助的话,点赞 + 关注+ 收藏 支持一下博主吧~

阅读指南

  • 开篇说明
  • 概念理解
  • 一、基础环境说明
    • 1.1 硬件环境
    • 1.2 软件环境
  • 二、下载与安装
    • 2.1 选择对应版本
    • 2.2 解压运行排除异常:
    • 2.3 关于使用
  • 三、最后

开篇说明

现在的反编译软件繁多,Apktool,JD-GUI,dedexer,IDA Pro等等,每种反编译工具都有各自使用的场景,例如Apktool我们在反编译apk类型文件时会用到,JD-GUI则是常用来反编译Java中的class文件,或者Jar等源文件;

在这里插入图片描述

概念理解

【1】什么是反编译?

简单的说,就是将机器语言转换成我们能看懂的语言,这个过程就叫反编译,例如Java中的class文件反编译后,就能变成我们日常开发写的代码xxx.java文件;

【2】反编译是否一定能成功?

不一定,随着现在很多代码编译中都会加入代码混淆,加密,或是加壳等等技术,加大反编译的难度和降低反编译代码的可读性,不过如果想完全避免反编译也是不可能的。只是反编译的还原度的大小问题了;

一、基础环境说明

考虑环境因素,大家适当的对比自己的软硬件环境情况分析~请仔细阅读硬件、软件环境

1.1 硬件环境

MacOS Monterey 版本 12.6.8 Apple M1

1.2 软件环境

JD-GUI版本:jd-gui-osx-1.6.6

二、下载与安装

Github下载JD-GUI软件github java-decompiler/jd-gui Public

2.1 选择对应版本

macOS系统我们选择jd-gui-osx-1.6.6.tar压缩包即可;

在这里插入图片描述

2.2 解压运行排除异常:

解压后,进入文件打开JD-GUI;
在这里插入图片描述
【注】运行时需要注意自己环境已经安装了JDK,否则你可能会遇到这样的错误:

在这里插入图片描述
若是确认JDK安装后,仍然提示该错误,需要修改文件->显示包内容->Contents->MacOs->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[@]}"}

2.3 关于使用

打开软件,选择自己要反编译的文件即可;
在这里插入图片描述
确认文件打开之后,我们就能看到反编译的源代码了;
在这里插入图片描述

三、最后

Windows的宝子们,方法上大同小异的,除了下载包区分一下,其他基本一致的问题;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/35480.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

GuiLite C语言实现版本

简介 本项目是idea4good/GuiLite的C语言实现版本&#xff0c;基于2024-06-20节点的版本&#xff08;提交ID&#xff1a;e9c4b57&#xff09;。 本项目仓库&#xff1a;GuiLite_C 需求说明 作为芯片从业人员&#xff0c;国产芯片普遍资源有限&#xff08;ROM和RAM比较少-都是…

[Vulnhub] wallabysnightmare LFI+RCE+Irssi聊天服务RCE

信息收集 Server IP AddressOpening Ports192.168.8.105TCP:22,80,6667,60080 $ nmap -p- -sC -sV 192.168.8.105 --min-rate 1000 -Pn 基础Shell http://192.168.8.105/?page../../../../../etc/shadow 当再次尝试访问已经关闭 $ nmap -p- -sC -sV 192.168.8.105 --min-rat…

【PTA】7-1 网红点打卡攻略(C/C++)代码实现 反思

解题细节分析&#xff1a; 0.比较图的两种存储方法&#xff0c;通过邻接矩阵存储更便于查找给定两点之间的关系 1.注意理解清楚题义&#xff1a;“访问所有网红点”中所有不是指攻略中所有&#xff0c;而是存在的全部的网红点 代码见下&#xff1a;// 需要注明的是&#xff…

锦江丽笙酒店稳步拓局海内外酒店市场 签约及意向合作20个新项目

&#xff08;中国上海&#xff0c;2024年6月27日&#xff09;民族品牌的国际化发展已日趋成为推动经济和文化交流的重要力量。作为民族品牌与国际品牌的融合发展&#xff0c;锦江丽笙酒店顺应市场趋势有序推进旗下品牌矩阵的全面布局&#xff1b;2024年上半年&#xff0c;已达成…

简易深度学习(1)深入分析神经元及多层感知机

一、神经元 单个神经元结构其实可以认为是一个线性回归模型。例如下图中 该神经元输入为三个特征&#xff08;x1&#xff0c;x2&#xff0c;x3&#xff09;&#xff0c;为了方便理解&#xff0c;大家可以认为每条线上都有一个权重和特征对应&#xff08;w1&#xff0c;w2&…

从源码到上线:直播带货系统与短视频商城APP开发全流程

很多人问小编&#xff0c;一个完整的直播带货系统和短视频商城APP是如何从源码开发到最终上线的呢&#xff1f;今天&#xff0c;笔者将详细介绍这一全过程。 一、需求分析与规划 1.市场调研与需求分析&#xff1a;首先需要进行市场调研&#xff0c;了解当前市场的需求和竞争情…

入职必备-Git 2种方式拉取代码

【SSH方式】: 1.复制电子邮箱 2.git bash 打开窗口 ssh-keygen -t rsa -C liuchangprimecare.group 3.一路回车&#xff0c;然后查看C:\Users\LiuChang.ssh里面的文件 打开id_rsa.pub文件&#xff0c;复制代码 4.添加到GitLab的公钥输入框 5.然后 git clone gitgitlab.pr…

使用容器配置文件构建任意应用镜像_并将应用镜像推送到公共仓库共享_应用分享与启动---分布式云原生部署架构搭建012

上面我们编写好了应用,并且,安装好了redis 现在我们把应用打包成镜像. 以前是这样做的,不方便,因为需要在服务器上,安装jdk什么的,现在有了 镜像就不用,给服务器安装镜像什么的了 以后所有机器都安装docker以后,就直接运行就可以了 首先看一下,安装java应用,需要 用到openjd…

指纹浏览器是什么?跨境多账号安全如何保证?

随着电子商务的蓬勃发展&#xff0c;越来越多的商家选择开设多店来扩大经营规模。然而多店运营也带来了一系列的挑战&#xff0c;其中之一就是账号安全。 1. 了解反检测浏览器和代理服务器 在我们开始讨论如何有效地使用反检测浏览器之前&#xff0c;我们首先需要了解这两个工…

openlayer 我的标注功能

背景&#xff1a; 通过openlayer库&#xff0c;可以在地图上实现绘制点、线、面。 并把绘制的结果添加到我的标注的弹框。 我的标注功能&#xff0c;包括&#xff1a;我的标注查询结果的数据展示&#xff1b;添加分组&#xff1b;添加我的标注&#xff1b;编辑分组、删除分组&a…

经典神经网络(13)GPT-1、GPT-2原理及nanoGPT源码分析(GPT-2)

经典神经网络(13)GPT-1、GPT-2原理及nanoGPT源码分析(GPT-2) 2022 年 11 月&#xff0c;ChatGPT 成功面世&#xff0c;成为历史上用户增长最快的消费者应用。与 Google、FaceBook等公司不同&#xff0c;OpenAI 从初代模型 GPT-1 开始&#xff0c;始终贯彻只有解码器&#xff0…

【机器学习300问】134、什么是主成分分析(PCA)?

假设你的房间堆满了各种各样的物品&#xff0c;书籍、衣服、玩具等等&#xff0c;它们杂乱无章地散落各处。现在&#xff0c;你想要清理房间&#xff0c;但又不想扔掉任何东西&#xff0c;只是希望让房间看起来更整洁&#xff0c;更容易管理。 你开始思考&#xff0c;能否将物品…

以数治税时代来临,企业如何应对?

全电发票是数字经济时代发票的新形态&#xff0c;顺应了数字经济潮流。现如今&#xff0c;国家正全力推动行业数字化进程&#xff0c;预计&#xff0c;2025年将基本实现发票全领域、全环节、全要素电子化&#xff0c;实现税务执法、服务、监管与大数据智能化应用深度融合、高效…

Spring事务的源码底层实现

文章目录 事务理论执行过程EnableTransactionManagement底层实现 事务 在线流程图 理论执行过程 通过事务管理器创建一个连接对象connection1设置事务隔离级别、是否只读等conn1.autocommit(false)将conn1存入ThreadLocal中Map<DataSource,Connection>执行目标方法、多…

Session会话与请求域的区别

session会话和请求域&#xff08;也称为request域&#xff09;都是用于存储和管理用户特定信息的重要概念&#xff0c;但它们在作用范围和生命周期上有显著的不同。 请求域 (Request Domain) 作用范围&#xff1a;请求域是面向单次请求的。每次HTTP请求都会创建一个新的request…

Java中的程序异常处理介绍

一、异常处理机制 Java提供了更加优秀的解决办法&#xff1a;异常处理机制。 异常处理机制能让程序在异常发生时&#xff0c;按照代码的预先设定的异常处理逻辑&#xff0c;针对性地处理异常&#xff0c;让程序尽最大可能恢复正常并继续执行&#xff0c;且保持代码的清晰。 Ja…

算法刷题日志 —— 数组和位运算

文章目录 [461. 汉明距离](https://leetcode.cn/problems/hamming-distance/submissions/542447020/)[448. 找到所有数组中消失的数字](https://leetcode.cn/problems/find-all-numbers-disappeared-in-an-array/submissions/)[136. 只出现一次的数字](https://leetcode.cn/pro…

最长回文串

描述&#xff1a; 最长回文串 思路&#xff1a; 统计每个字母出现次数&#xff0c;如果是偶数&#xff0c;ret x;如果是存在奇数的话&#xff0c;就可以放在中间&#xff0c;ret 1. 代码&#xff1a; class Solution { public:int hash[200];int longestPalindrome(str…

AI智能修复视频,垃圾画质也变高清 HD——牛小影

很多时候&#xff0c;从网上下载的视频或监控视频都是模糊的。有什么方法或者软件可以让哪些模糊的视频恢复清晰吗&#xff1f;今天就给大家推荐一个可以使模糊的视频变清晰的软件。 我们都知道用PS或者一些修复工具可以修复模糊的图片&#xff0c;但是很多人不知道的是视频也可…

构建LangChain应用程序的示例代码:46、使用 Meta-Prompt 构建自我改进代理的 LangChain 实现

Meta-Prompt 实现 摘要&#xff1a; 本文介绍了 Noah Goodman 提出的 Meta-Prompt 方法的 LangChain 实现&#xff0c;该方法用于构建能够自我反思和改进的智能代理。 核心思想&#xff1a; Meta-Prompt 的核心思想是促使代理反思自己的性能&#xff0c;并修改自己的指令。…