简体   繁体   English

在Eclipse中,如何将项目导出到ZIP,包括引用的库?

[英]In Eclipse, how to export a project to ZIP including referenced libraries?

My lecturer required a ZIP file containing my project, which he will import into Eclipse on his machine. 我的讲师需要一个包含我的项目的ZIP文件,他将在他的机器上导入Eclipse。 I cannot guarantee he has jUnit on his machine, but I used jUnit in my project. 我无法保证他的机器上有jUnit,但我在项目中使用了jUnit。

If I simply export the project to a ZIP (File > Export > Archive File ...) will the ZIP include (my version of) jUnit ? 如果我只是将项目导出到ZIP(文件>导出>存档文件...) ,ZIP将包括(我的版本)jUnit And if not, how can I include jUnit in the ZIP? 如果没有,我如何在ZIP中包含jUnit?

Edit : Tested the import of a ZIP file, generated as above, on a fresh installation of Eclipse, on a virtual machine, and jUnit was there. 编辑 :在虚拟机上测试了在全新安装的Eclipse上导入的ZIP文件(如上所述),并且jUnit就在那里。 When inspecting the .class file of the project I saw that it provides a URL to jUnit. 在检查项目的.class文件时,我看到它提供了一个指向jUnit的URL。 So I guess my question has become: Where does Eclipse import jUnit from? 所以我想我的问题已成为: Eclipse从哪里导入jUnit? And will this work in any setup of Eclipse (ie OS, version of Eclipse)? 这将在Eclipse的任何设置(即操作系统,Eclipse版本)中工作吗?

JUnit comes standard with the download of any version of Eclipse. JUnit标配下载任何版本的Eclipse。 To use it, a new .java file needs to be created ( File > New > JUnit Test Case ). 要使用它,需要创建一个新的.java文件( File > New > JUnit Test Case )。 Find your program package and then name your .java file (usually something similar to the class which is being tested) 找到你的程序包,然后命名你的.java文件(通常类似于正在测试的类)

Example: 例:
Name: HelloWorldTest 名称:HelloWorldTest
Class under test: HelloWorld 被测试的类:HelloWorld

If you ever find the JUnit library is corrupt or isn't working again, you can download the current version straight from the web site 如果您发现JUnit库已损坏或无法再次运行,您可以直接从网站下载当前版本

JUnit comes with eclipse itself. JUnit自带了eclipse。 It is usually the latest version. 它通常是最新版本。 If you want to use any other version of Junit then you have to manually import the libraries to your project. 如果要使用任何其他版本的Junit,则必须手动将库导入项目。

Now coming to your question that if you archive the project and share it with your lecturer then the zip file will not have the Junit library but it gets imported from eclipse libraries when the project is built. 现在回答您的问题,如果您将项目归档并与讲师共享,那么zip文件将没有Junit库,但是在构建项目时它将从eclipse库导入。 Again it is a specific version of JUnit depending on which eclipse version you are using. 同样,它是JUnit的特定版本,具体取决于您使用的是哪个eclipse版本。 Few more details are mentioned HERE 这里提到的细节很少

You can check the version of Junit that eclipse provides as mentioned HERE 您可以检查的JUnit Eclipse提供所提到的版本HERE

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

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