eclipse 无法将我的任何项目导出到 .jar 文件中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25473049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to export any of my projects into a .jar file
提问by Zahachos
Everytime I try to export any of the projects from my workspace into a Java jar file, I end up with an error:
每次我尝试将任何项目从我的工作区导出到 Java jar 文件时,我都会遇到错误:
JAR creation failed. See details for additional information. Class files on classpath not found or not accessible for: 'Server Manager/src/me/Zahach/ServerManager/main.java'
JAR 创建失败。有关其他信息,请参阅详细信息。找不到或无法访问类路径上的类文件:“服务器管理器/src/me/Zahach/ServerManager/main.java”
And this error is repeated for every class in my project.
对于我的项目中的每个类,都会重复此错误。
I tried reinstalling Eclipse, that didn't work. I then tried to recreate a project and drag and drop my packages into it, that didn't work either.
我尝试重新安装 Eclipse,这没有用。然后我尝试重新创建一个项目并将我的包拖放到其中,这也不起作用。
What is going on?
到底是怎么回事?
回答by evenprime
The error is caused because of a missing .class
file(s) for corresponding .java
file(s)
该错误是由于.class
相应.java
文件的文件丢失引起的
In Eclipse
Goto
Project->Clean
andRebuild
the Project and then try exporting,
If it doesn't work then make sure.class
file exists in the bin folder formain.java
file in your caseAnother solution is to ensure that the Classpath is Valid
在日食中
转到
Project->Clean
和Rebuild
项目,然后尝试导出,
如果它不起作用,请确保.class
文件在 bin 文件夹中存在main.java
于您的案例中另一种解决方案是确保Classpath 有效
回答by alexandru.asandei89
Also make sure that the permissions in your workspace folders are ok. I ran into this problem after updating Eclipse and then downloading some Maven dependencies.
In the end, what fixed it was doing a sudo chmod 777 -R workspace/MyProject
还要确保工作区文件夹中的权限没问题。我在更新 Eclipse 然后下载了一些 Maven 依赖项后遇到了这个问题。最后,修复它的是做一个sudo chmod 777 -R workspace/MyProject
回答by krishna chaitanya Pullakandam
I have faced similar problem while exporting my java files into a compressed jar file, so I checked the Java Build Path of my project and found that the External jars I was referring to from the project are not present in the designated folder locations. Once I have resolved that, I was able to export my java files into a jar.
我在将我的 java 文件导出到压缩的 jar 文件时遇到了类似的问题,所以我检查了我的项目的 Java Build Path,发现我从项目中引用的外部 jars 不存在于指定的文件夹位置。一旦我解决了这个问题,我就可以将我的 java 文件导出到一个 jar 中。
回答by dreamcrash
I had the same problem, but even following the steps of the accepted answer it did not work. For some reason it was not producing the my_file.class. However, I find a trick that might help others, I rename the "my_file" and build again and it worked fine.
我遇到了同样的问题,但即使按照已接受的答案的步骤也没有奏效。出于某种原因,它没有生成 my_file.class。但是,我找到了一个可能对其他人有帮助的技巧,我重命名了“my_file”并再次构建,它运行良好。
回答by Zameer
You may have any java file that is totally empty. You have that file in project with somethingName.java but inside it is nothing. So no bytecode gets generated for it and it throws an error. You can find that file in error details and delete it and try building jar again. It works :) Thumbs up
您可能有任何完全空的 java 文件。您在项目中使用 somethingName.java 拥有该文件,但在其中什么都没有。所以没有为它生成字节码,它会抛出一个错误。您可以在错误详细信息中找到该文件并将其删除,然后再次尝试构建 jar。它有效:) 竖起大拇指
回答by Bret Hogg
I had empty Java file classes causing the error.
我有导致错误的空 Java 文件类。