今天有人問到 META-INF文件夾是幹啥的,META-INF文件夾的做用, META-INF文件夾能刪嗎,還有項目的META-INF下面通常會有個MANIFEST.MF 文件,都是幹啥的。html
百度搜了一下,基本找不到答案。因而上stakoverflow搜,獲得以下答案:java
If you remove META-INF from a jar then there is no MANIFEST.MF and so java -jar can't find the main class.apache
You can create jars without META-INF but when you are going to execute a jar a META-INF/MANIFEST.MF is required.oracle
See http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.htmleclipse
這句英文很簡單,簡單翻譯以下:ide
若是你將Jar中的META-INF文件夾刪除,那麼jar文件裏邊就沒有MANIFEST.MF文件。那麼,java -jar就找不到main class.ui
沒有META-INF你仍然能夠建立一個Jar文件。可是,當你想要執行jar文件的時候,這個jar是須要具有 META-INF/MANIFEST.MF的。翻譯
咱們在使用eclipse或者myeclipse新建項目以後,在項目中能夠找到META-INF文件夾,下面有個MANIFEST.MF。htm
打開以後發現裏邊只有:blog
Manifest-Version: 1.0 Class-Path:
瞬間變有疑問:這麼少點信息,有啥做用。爲啥上面那段英文說的這個文件這麼的不可或缺。
因而我隨便在項目的lib中找了一個jar文件commons-io-2.3.jar,打開,把裏邊的MANIFEST.MF文件拿出來,打開以下:
Manifest-Version: 1.0 Export-Package: org.apache.commons.io.output;version="2.3",org.apache. commons.io.monitor;version="2.3",org.apache.commons.io.filefilter;ver sion="2.3",org.apache.commons.io.comparator;version="2.3",org.apache. commons.io.input;version="2.3",org.apache.commons.io;version="2.3" Implementation-Title: Commons IO Built-By: ggregory Tool: Bnd-1.50.0 Implementation-Vendor: The Apache Software Foundation Implementation-Vendor-Id: org.apache Specification-Title: Commons IO Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-SymbolicName: org.apache.commons.io X-Compile-Target-JDK: 1.6 Implementation-Version: 2.3 Specification-Vendor: The Apache Software Foundation Bundle-Name: Commons IO Created-By: Apache Maven Bundle Plugin X-Compile-Source-JDK: 1.6 Bundle-Vendor: The Apache Software Foundation Build-Jdk: 1.6.0_31 Bundle-Version: 2.3.0 Bnd-LastModified: 1334069963279 Bundle-ManifestVersion: 2 Bundle-Description: The Commons IO library contains utility classes, s tream implementations, file filters, file comparators, endian transfo rmation classes, and much more. Bundle-DocURL: http://commons.apache.org/io/ Implementation-Build: tags/2.3-RC1@r1311772; 2012-04-10 10:59:15-0400 Specification-Version: 2.3 Include-Resource: META-INF/LICENSE.txt=LICENSE.txt,META-INF/NOTICE.txt =NOTICE.txt Archiver-Version: Plexus Archiver
密密麻麻一大片,是一行行的,相似配置文件,前面一個'key' 後面一個‘value’
具體這些玩意有啥用,META-INF 裏邊還能夠放啥,可擊上面文字中提供的的鏈接。好長一片英文,感興趣的話,慢慢看吧。