[英]Why all programs in intellij results in class not found error
所以,我试图运行我得到以下错误的源代码
据我所知,这是我的目录文件夹,定义类和目录的名称没有问题。 我尝试运行的代码是 Deitel Java 如何编程的示例。
package Concurrency;
import java.security.SecureRandom;
import java.text.NumberFormat;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
public class SortComparison {
public static void main(String[] args) {
SecureRandom generator = new SecureRandom();
int[] array1 = generator.ints(15_000_000).toArray();
int[] array2 = new int[array1.length];
System.arraycopy(array1, 0, array2, 0, array1.length);
System.out.println("Starting sort");
Instant sortStart = Instant.now();
Arrays.sort(array1);
Instant sortEnd = Instant.now();
long sortTime = Duration.between(sortStart, sortEnd).toMillis();
System.out.printf("Total time in milliseconds: %d%n%n", sortTime);
System.out.println("Starting parallelSort");
Instant parallelSortStart = Instant.now();
Arrays.parallelSort(array2);
Instant parallelSortEnd = Instant.now();
long parallelSortTime =
Duration.between(parallelSortStart, parallelSortEnd).toMillis();
System.out.printf("Total time in milliseconds: %d%n%n",
parallelSortTime);
String percentage = NumberFormat.getPercentInstance().format(
(double) sortTime / parallelSortTime);
System.out.printf("%nSort took %s more time than parallelSort%n",
percentage);
}
}
然后我尝试将我正在使用的 JDK 版本从版本 12 更改为 11,然后其他项目也发生了同样的事情。
事情甚至变得更好:)))。 我试图创建一个简单的 hello world 项目,然后同样的事情发生在那里。 Intellij Idea 或我的 java 版本有问题吗? 现在,我有 JDK 版本 13。我应该重新安装 Intellij 还是有替代方案?
你可能移动了你的主要 class。 检查你的运行配置
确保在执行运行/调试配置之前构建项目,或者运行配置在启动前部分中有Make步骤。
确保在使用模块的类路径下拉菜单中指定了正确的模块
检查模块的编译器 output 目录是否确实有这个编译的 class。 IDE 在项目构建时将 class 复制到那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.