输入重定向到Java - 无法找到或加载主类 [英] Input redirection into Java - Could not find or load main class
本文介绍了输入重定向到Java - 无法找到或加载主类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了每个在线解决方案,但我仍然得到相同的结果..我正在尝试让我的代码在distinct.txt文件上运行,这是我尝试运行它。
I tried every online solution and i still get the same result..i'm trying to get my code to run on a file "distinct.txt" and here is my attempt to run it.
我尝试了不同的路径并且都给出了相同的结果。
i tried different paths and all give same result.
这是我的代码
package pset2.sol;
import edu.princeton.cs.algs4.StdIn;
public class Permutation {
public static void main(String[] args){
RandomizedQueue<String> rq = new RandomizedQueue<>();
while (!StdIn.isEmpty()) {
String item = StdIn.readString();
rq.enqueue(item);
}
int k = Integer.parseInt(args[0]);
for(int i = 0; i < k; i++){
System.out.println(rq.dequeue());
}
}
}
推荐答案
我的猜测是你的源文件夹设置不正确。
My guess is that your source-folder is not set correctly.
尝试文件 - >项目结构 - >模块 - >(标签)来源 - >马克as:Sources。
Try File -> Project Structure -> Modules -> (tab) Sources -> Mark as: Sources.
导入Eclipse项目后,我解决了这个问题。
That fixed the problem for me after importing an Eclipse Project.
这篇关于输入重定向到Java - 无法找到或加载主类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文