gpt4 book ai didi

java - 使用 VSCode 并获取 NoClassDefFoundError

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

我通常使用像 IntelliJ 这样的 IDE,但我尝试迁移到 VSCode,但我不明白为什么我正在处理 IntelliJ 的项目运行良好,但当我在 VSCode 中打开该项目时,我收到了该错误。我看过这个问题的其他答案,但他们都提到了 bin、src 和 classpath 等我不太熟悉的东西。我想如果你通过cmd运行java,但我不这样做。我该如何解决这个问题?

我的文件位于 D:\Antonio\Documents\GitLab\ProjectEuler-Java\Solved_Problems

package Solved_Problems;

class Problem_001_MultiplesOf3And5{

// Multiples of 3 and 5

/*
*
* If we list all the natural numbers below 10 that are multiples of 3 or 5, we
* get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the
* multiples of 3 or 5 below 1000.
*
*/

public static void main(String[] args) {

int totalsum = 0;

for (int i = 1; i < 1000; i++) {
if ((i % 3 == 0) || (i % 5 == 0))
totalsum += i;
}

System.out.println(totalsum);

}

}

输出:

Error: Could not find or load main class Problem_001_MultiplesOf3And5
Caused by: java.lang.ClassNotFoundException: Problem_001_MultiplesOf3And5

[Done] exited with code=1 in 0.835 seconds

最佳答案

你尝试这样做:

cd d:\Antonio\Documents\GitLab\ProjectEuler-Java\Solved_Problems

javac Problem_001_MultiplesOf3And5.java

cd..

然后

java Solved_Problems.Problem_001_MultiplesOf3And5(包+类)

关于java - 使用 VSCode 并获取 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56417738/

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