gpt4 book ai didi

java - 捕获标志错误: could not find or load main class Espresso

转载 作者:行者123 更新时间:2023-12-02 01:43:53 25 4
gpt4 key购买 nike

您好,我正在捕获标志事件,当前问题出在 Java 中,但我没有任何使用 Java 的经验。当我尝试运行该文件时,我收到“无法找到或加载主类 Espresso”。我在这里看过其他帖子,我尝试过 java -cp . Espresso但没有任何运气。我确实跑了javac Espresso.java在运行之前编译它 java Espresso 。任何帮助将不胜感激,这里的代码是:

package com.hackinglab.ctf;
import java.io.PrintStream;

public class Espresso { public Espresso() {} private static String key = "Stringab";
private static String cipher = "'>xgx47#)~Fp?8k4%IHsC9_a";

public static void main(String[] paramArrayOfString) {
if (paramArrayOfString.length != 1) {
System.out.println("You must enter the flag.");
System.exit(-1);
}
String str = paramArrayOfString[0];
System.out.println(str);
StringBuffer localStringBuffer = new StringBuffer();
for (int i = 0; i < cipher.length(); i++) {
localStringBuffer.append((char)(key.charAt(i % key.length()) - cipher.charAt(i) + 55));
}
if (localStringBuffer.toString().equals(str)) {
System.out.println("Flag correct, well done!");
} else {
System.out.println("Dude, that's wrong!");
}
}
}

最佳答案

确保您的文件夹结构与包名称相同

../com/hackinglab/ctf/Espresso.java

然后你可以像这样构建并运行它

javac com/hackinglab/ctf/Espresso.java
java com/hackinglab/ctf/Espresso

或从源文件中删除行package com.hackinglab.ctf;

关于java - 捕获标志错误: could not find or load main class Espresso,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53991620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com