META-INF的目的是什么? [英] What's the purpose of META-INF?
问题描述
在Java中,您经常会看到包含一些元文件的META-INF文件夹。这个文件夹的目的是什么,我可以放在那里?
In Java, you often see a META-INF folder containing some meta files. What is the purpose of this folder and what can I put there?
推荐答案
一般来说,你不应该把任何东西放到META- INF自己。相反,你应该依靠你用来打包你的JAR的任何东西。这是我认为Ant真正擅长的领域之一:指定JAR文件清单属性。这很容易说:
Generally speaking, you should not put anything into META-INF yourself. Instead, you should rely upon whatever you use to package up your JAR. This is one of the areas where I think Ant really excels: specifying JAR file manifest attributes. It's very easy to say something like:
<jar ...>
<manifest>
<attribute name="Main-Class" value="MyApplication"/>
</manifest>
</jar>
至少,我觉得这很容易......: - )
At least, I think that's easy... :-)
重点是META-INF应被视为内部Java meta 目录。别乱吧!您希望包含在JAR中的任何文件都应放在其他子目录中或JAR本身的根目录下。
The point is that META-INF should be considered an internal Java meta directory. Don't mess with it! Any files you want to include with your JAR should be placed in some other sub-directory or at the root of the JAR itself.
这篇关于META-INF的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!