javameta-inf

What's the purpose of 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?


Solution

  • 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... :-)

    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.