新来的Java库 - 如何在一个jar文件包括 [英] New to java libraries - what to include in a jar file
问题描述
我有一个Android项目,其中包括与文件复制方法的类。出于兴趣,我想我会提取这种成(非Android,只是普通的java)它自己的项目,它的东西,其他的项目可以利用的。
I have an Android project which included a class with a file copy method. Out of interest I thought I'd extract this into a (non-android, just plain java) project of its own, as it's something that other projects could make use of.
然后我想我会看看创建这一新项目的JAR,所以其他项目可以只是罐子在一个'库'的文件夹,并引用它作为一个库,而不是我不得不导入项目在Eclipse等。
I then thought I'd take a look at creating a jar from this new project, so other project could just have the jar in a 'lib' folder and reference it as a library, rather than me having to import the project in eclipse etc.
我的问题是,我应该被包括在JAR文件中,当我经过罐子导出向导在日食?它的看起来的到,如果我的项目包含多单文件的更多,并且有多个包等。我将需要的.classpath和.project例如工作,如果我只包括* .class文件,但什么?
My question is, what should I be including in the jar file when I go through the jar export wizard in eclipse? It seems to work if I just include the *.class file but what if my project contained more than a single file, and had multiple packages etc. Would I need the .classpath and .project for example?
谢谢,
巴里
推荐答案
您可以包括需要在运行时的东西。
You can include things that are needed at runtime.
例如:
- .class文件包含编译code;这是需要在运行时。
- 您可能还需要包括其他资源,如图像。
- 有时你可能会发现它很方便,包括自定义的META-INF / MANIFEST.MF。
- 有时是非常有用的包括一个动态链接,本地库(例如,一个Windows DLL),但使用它,你通常需要先解压到一个临时位置。
- 有时更多的资源被压缩到一个罐子,如用于库的API文档。
。项目和classpath文件不会在运行时使用。它们不需要被包括在jar文件
The .project and .classpath files are not used at runtime. They do not need to be included in the jar file.
这篇关于新来的Java库 - 如何在一个jar文件包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!