質問するログイン新規登録
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Q&A

1回答

698閲覧

githubのghidra.batを開けない

tazutaka

総合スコア0

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

0グッド

0クリップ

投稿2024/08/11 08:54

0

0

実現したいこと

githubからインストールしたghidra.batを開きたい java --versionでは
java 22.0.2 2024-07-16
Java(TM) SE Runtime Environment (build 22.0.2+9-70)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)となる。

発生している問題・分からないこと

ghidra.batをwindowsのコマンドプロンプトで開こうとしたが、以下のようなエラーが表示される。

エラーメッセージ

error

1Microsoft Windows [Version 10.0.22000.2416] 2(c) Microsoft Corporation. All rights reserved. 3 4C:\Users\tazu0>C:\Users\tazu0\OneDrive\デスクトップ\ghidra_11.1.2_PUBLIC_20240709\ghidra_11.1.2_PUBLIC\ghidraRun.bat 5'java -cp "C:\Users\tazu0\OneDrive\デスクトップ\ghidra_11.1.2_PUBLIC_20240709\ghidra_11.1.2_PUBLIC\support\LaunchSupport.jar" LaunchSupport "C:\Users\tazu0\OneDrive\デスクトップ\ghidra_11.1.2_PUBLIC_20240709\ghidra_11.1.2_PUBLIC\support\.." -jdk_home -save' は、内部コマンドまたは外部コマンド、 6操作可能なプログラムまたはバッチ ファイルとして認識されていません。 7****************************************************************** 8JDK 17+ (64-bit) could not be found and must be manually chosen! 9****************************************************************** 10Enter path to JDK home directory (ENTER for dialog): 11 12 13

該当のソースコード

ghidra.bat

1#!/usr/bin/env bash 2 3#---------------------------------------- 4# Ghidra launch 5#---------------------------------------- 6 7# Maximum heap memory may be changed if default is inadequate. This will generally be up to 1/4 of 8# the physical memory available to the OS. Uncomment MAXMEM setting if non-default value is needed. 9#MAXMEM=2G 10 11# Resolve symbolic link if present and get the directory this script lives in. 12# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD 13# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the 14# fallback, which doesn't attempt to do anything with links. 15SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" 16SCRIPT_DIR="${SCRIPT_FILE%/*}" 17 18# Launch Ghidra 19"${SCRIPT_DIR}"/support/launch.sh bg jdk Ghidra "${MAXMEM}" "" ghidra.GhidraRun "$@"

launch.sh

1#!/usr/bin/env bash 2## ### 3# IP: GHIDRA 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16## 17 18umask 027 19 20function showUsage() { 21 22 echo "Usage: $0 <mode> <java-type> <name> <max-memory> \"<vmarg-list>\" <app-classname> <app-args>... " 23 echo " <mode>: fg run as foreground process in current shell" 24 echo " bg run as background process in new shell" 25 echo " debug run as foreground process in current shell in debug mode (suspend=n)" 26 echo " debug-suspend run as foreground process in current shell in debug mode (suspend=y)" 27 echo " NOTE: for all debug modes environment variable DEBUG_ADDRESS may be set to " 28 echo " override default debug address of 127.0.0.1:18001" 29 echo " <java-type>: jdk requires JDK to run" 30 echo " jre JRE is sufficient to run (JDK works too)" 31 echo " <name>: application name used for naming console window" 32 echo " <max-memory>: maximum memory heap size in MB (e.g., 768M or 2G). Use empty \"\" if default" 33 echo " should be used. This will generally be upto 1/4 of the physical memory available" 34 echo " to the OS." 35 echo " <vmarg-list>: pass-thru args (e.g., \"-Xmx512M -Dmyvar=1 -DanotherVar=2\"). Use" 36 echo " empty \"\" if vmargs not needed. Spaces are not supported." 37 echo " <app-classname>: application classname (e.g., ghidra.GhidraRun )" 38 echo " <app-args>...: arguments to be passed to the application" 39 echo " " 40 echo " Example:" 41 echo " \"$0\" debug jdk Ghidra 4G \"\" ghidra.GhidraRun" 42 43 exit 1 44} 45 46 47VMARGS_FROM_CALLER= # Passed in from the outer script as one long string, no spaces 48VMARGS_FROM_LAUNCH_SH=() # Defined in this script, added to array 49VMARGS_FROM_LAUNCH_PROPS=() # Retrieved from LaunchSupport, added to array 50 51ARGS=() 52INDEX=0 53WHITESPACE="[[:space:]]" 54 55for AA in "$@" 56do 57 INDEX=$(expr $INDEX + 1) 58 case "$INDEX" in 59 1) 60 MODE=$AA 61 ;; 62 2) 63 if [ "$AA" = "jre" ]; then 64 JAVA_TYPE_ARG="-java_home" 65 else 66 JAVA_TYPE_ARG="-jdk_home" 67 fi 68 ;; 69 3) 70 APPNAME=$AA 71 ;; 72 4) 73 MAXMEM=$AA 74 ;; 75 5) 76 if [ "$AA" != "" ]; then 77 VMARGS_FROM_CALLER=$AA 78 fi 79 ;; 80 6) 81 CLASSNAME=$AA 82 ;; 83 *) 84 ARGS[${#ARGS[@]}]=$AA 85 ;; 86 esac 87done 88 89# Verify that required number of args were provided 90if [[ ${INDEX} -lt 6 ]]; then 91 echo "Incorrect launch usage - missing argument(s)" 92 showUsage 93 exit 1 94fi 95 96# Sets SUPPORT_DIR to the directory that contains this file (launch.sh) 97SUPPORT_DIR="${0%/*}" 98 99# Ensure Ghidra path doesn't contain illegal characters 100if [[ "$SUPPORT_DIR" = *"!"* ]]; then 101 echo "Ghidra path cannot contain a \"!\" character." 102 exit 1 103fi 104 105if [ -f "${SUPPORT_DIR}/launch.properties" ]; then 106 107 # Production Environment 108 INSTALL_DIR="${SUPPORT_DIR}/.." 109 CPATH="${INSTALL_DIR}/Ghidra/Framework/Utility/lib/Utility.jar" 110 LS_CPATH="${SUPPORT_DIR}/LaunchSupport.jar" 111 DEBUG_LOG4J="${SUPPORT_DIR}/debug.log4j.xml" 112else 113 114 # Development Environment (Eclipse classes or "gradle jar") 115 INSTALL_DIR="${SUPPORT_DIR}/../../../.." 116 CPATH="${INSTALL_DIR}/Ghidra/Framework/Utility/bin/main" 117 LS_CPATH="${INSTALL_DIR}/GhidraBuild/LaunchSupport/bin/main" 118 if ! [ -d "${LS_CPATH}" ]; then 119 CPATH="${INSTALL_DIR}/Ghidra/Framework/Utility/build/libs/Utility.jar" 120 LS_CPATH="${INSTALL_DIR}/GhidraBuild/LaunchSupport/build/libs/LaunchSupport.jar" 121 if ! [ -f "${LS_CPATH}" ]; then 122 echo "Cannot launch from repo because Ghidra has not been compiled with Eclipse or Gradle." 123 exit 1 124 fi 125 fi 126 DEBUG_LOG4J="${INSTALL_DIR}/Ghidra/RuntimeScripts/Common/support/debug.log4j.xml" 127fi 128 129# Make sure some kind of java is on the path. It's required to run the LaunchSupport program. 130if ! [ -x "$(command -v java)" ] ; then 131 echo "Java runtime not found. Please refer to the Ghidra Installation Guide's Troubleshooting section." 132 exit 1 133fi 134 135# Get the JDK that will be used to launch Ghidra 136JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)" 137if [ ! $? -eq 0 ]; then 138 # If fd 0 (stdin) isn't a tty, fail because we can't prompt the user 139 if [ ! -t 0 ]; then 140 echo 141 echo "Unable to prompt user for JDK path, no TTY detected. Please refer to the Ghidra Installation Guide's Troubleshooting section." 142 exit 1 143 fi 144 145 # No JDK has been setup yet. Let the user choose one. 146 java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -ask 147 148 # Now that the user chose one, try again to get the JDK that will be used to launch Ghidra 149 JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" ${JAVA_TYPE_ARG} -save)" 150 if [ ! $? -eq 0 ]; then 151 echo 152 echo "Failed to find a supported JDK. Please refer to the Ghidra Installation Guide's Troubleshooting section." 153 exit 1 154 fi 155fi 156JAVA_CMD="${JAVA_HOME}/bin/java" 157 158# Get the configurable VM arguments from the launch properties 159while IFS=$'\r\n' read -r line; do 160 VMARGS_FROM_LAUNCH_PROPS+=("$line") 161done < <(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -vmargs) 162 163

試したこと・調べたこと

  • teratailやGoogle等で検索した
  • ソースコードを自分なりに変更した
  • 知人に聞いた
  • その他
上記の詳細・結果

OneDriveではない場所)にファイル一式を移動して、そちらで試した。java sdkを入れ直したり、pathを削除したりもした。しかし、同じようにしかならなかった。

補足

特になし

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

Windowsで実行するのに、間違ってLinux用のファイルを取得してしまっていますね。
Windowsで実行するなら、Windowsファイルを使いましょう。
WSLの中で実行するつもりで、意図的にLinux用を取得したのなら、WSLの中で実行しましょう。

投稿2024/08/12 08:17

otn

総合スコア86372

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

otn

2024/08/12 08:38

普通にgit clone すると、~\RuntimeScripts\Windows の下にghidraRun.batというのがあるようです。
tazutaka

2024/08/12 23:11

windows用とLinux用はどうやって見分けるのですか?
otn

2024/08/12 23:50

> windows用とLinux用はどうやって見分けるのですか? どうやって取得したのでしょうか? 違い自体はファイルの中味を見れば分かりますが、普通は置き場所が違います。
tazutaka

2024/08/13 03:59

>違い自体はファイルの中味を見れば分かりますが、 その違いを良ければ教えていただけませんか?
otn

2024/08/13 09:11

> githubからdownloadしました。https://github.com/NationalSecurityAgency/ghidra/releases 質問は、「どうやって取得したのでしょうか?」で、「どこから取得したのでしょうか?」ではないです。 gitコマンドやgitのアプリを使わず、ブラウザーでzipファイルをダウンロードして解凍したということですかね? で、Windowsで実行するのにも関わらず、zip解凍後の直下にあるBATファイルを無視して、拡張子の無いファイルを拡張子BATにリネームして実行したということですかね?結果から見るとそう見えますが、どこかに「そうしろ」と書いてあったのでしょうか? 私はドキュメントを読んでないので、「ghidraRun.batを実行する」ことが最初にやるべき手順なのかどうか知りませんが。 >違い自体はファイルの中味を見れば分かりますが、 その違いを良ければ教えていただけませんか? スクリプトの文法も違うし、コマンドも違う。今回はファイルの拡張子も違うし。 見比べて「同じに見える」ということでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.30%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問