简体   繁体   English

在 Eclipse 中使用可运行的 Jar 文件时出现 FileNotFoundException 错误

[英]FileNotFoundException error when using a runnable Jar File in Eclipse

I am working on an assignment that involves the use of 2 txt files and creating a runnable jar file.我正在处理一项涉及使用 2 个 txt 文件并创建可运行的 jar 文件的任务。 Part of the assignment involves creating a runnable jar file called Hw2.jar, exporting that file into the "first directory level", then going into run configurations in the arguments tab and pasting, "java -jar hw2.jar ct.search ct.corpus" (the ct.search and ct.corpus files are the txt files) Here is what it looks like. Part of the assignment involves creating a runnable jar file called Hw2.jar, exporting that file into the "first directory level", then going into run configurations in the arguments tab and pasting, "java -jar hw2.jar ct.search ct. corpus”(ct.search 和 ct.corpus 文件是 txt 文件)这是它的样子。

这是我的项目文件的样子,目录中有 hw2.jar 文件

这是运行配置的样子

Yet despite having completed the steps, I'm getting a FileNotFoundException Error, as detailed below.然而,尽管完成了这些步骤,我还是收到了 FileNotFoundException 错误,如下所述。

Exception in thread "main" java.io.FileNotFoundException: -jar (The system cannot find the file specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.(Unknown Source) at java.io.FileInputStream.(Unknown Source) at java.io.FileReader.(Unknown Source) at edu.iastate.cs228.hw2.Console.main(Console.java:29) Exception in thread "main" java.io.FileNotFoundException: -jar (The system cannot find the file specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java. io.FileInputStream.(Unknown Source) at java.io.FileInputStream.(Unknown Source) at java.io.FileReader.(Unknown Source) at edu.iastate.cs228.hw2.Console.main(Console.java:29)

This is my first time trying to use a runnable jar file within the run configurations, so I am unfamiliar with how exactly the process works.这是我第一次尝试在运行配置中使用可运行的 jar 文件,所以我不熟悉该过程的具体工作原理。 I would very much appreciate any help with this issue.我将非常感谢有关此问题的任何帮助。 Thank you.谢谢你。

EDIT: The jar and txt files are NOT in the src folder.编辑: jar 和 txt 文件不在 src 文件夹中。 They are inside of the project folder.它们位于项目文件夹中。

From your first screenshot, it looks like all of the corpus files and the jar are inside the src folder (you can confirm if this is the case if you collapse the src folder by clicking on the triangle icon).从您的第一个屏幕截图中,看起来所有的语料库文件和 jar 都在src文件夹中(如果您通过单击三角形图标折叠src文件夹,您可以确认是否是这种情况)。 Use cut and paste them at the project level.在项目级别使用剪切和粘贴它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM