Netbeans项目中没有默认的META-INF文件夹 - 在哪里添加文件?

时间:2013-03-21 11:23:00

标签: netbeans jar manifest manifest.mf meta-inf

如何让Netbeans将javamail.providers添加到META-INF文件夹(我手动添加)中,而不会进入ant构建文件中的杂草?

有点奇怪,因为manifest.mf最终出现在生成的jar中的META-INF文件夹中(正确)但是位于META-INF文件夹(我手动添加)之外:

thufir@dur:~/NetBeansProjects/gnumail-providers$ 
thufir@dur:~/NetBeansProjects/gnumail-providers$ ll META-INF/
total 12
drwxrwxr-x 2 thufir thufir 4096 Mar 21 04:02 ./
drwxr-xr-x 8 thufir thufir 4096 Mar 21 04:15 ../
-rw-rw-r-- 1 thufir thufir  868 Mar 21 04:02 javamail.providers
thufir@dur:~/NetBeansProjects/gnumail-providers$ 
thufir@dur:~/NetBeansProjects/gnumail-providers$ ll manifest.mf 
-rw-rw-r-- 1 thufir thufir 82 Mar 21 03:18 manifest.mf
thufir@dur:~/NetBeansProjects/gnumail-providers$ 

这是项目:

thufir@dur:~/NetBeansProjects/gnumail-providers$ 
thufir@dur:~/NetBeansProjects/gnumail-providers$ tree -L 2
.
├── build
│   ├── built-jar.properties
│   ├── classes
│   ├── empty
│   └── generated-sources
├── build.xml
├── dist
│   ├── gnu
│   ├── gnumail-providers.jar
│   ├── META-INF
│   ├── net
│   ├── providers
│   ├── treeutil
│   └── usenet.properties
├── javamail.providers
├── manifest.mf
├── META-INF
│   └── javamail.providers
├── nbproject
│   ├── build-impl.xml
│   ├── genfiles.properties
│   ├── private
│   ├── project.properties
│   └── project.xml
└── src
    ├── gnu
    ├── net
    ├── providers
    ├── treeutil
    └── usenet.properties

18 directories, 12 files
thufir@dur:~/NetBeansProjects/gnumail-providers$ 

这是Netbeans构建的结果JAR:

thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ 
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ ll
total 228
drwxrwxr-x 3 thufir thufir   4096 Mar 21 04:15 ./
drwxr-xr-x 8 thufir thufir   4096 Mar 21 04:15 ../
-rw-rw-r-- 1 thufir thufir 213021 Mar 21 04:15 gnumail-providers.jar
drwxrwxr-x 2 thufir thufir   4096 Mar 21 04:15 lib/
-rw-rw-r-- 1 thufir thufir   1332 Mar 21 04:15 README.TXT
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ 
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ jar -xf gnumail-providers.jar 
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ 
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ ll
total 252
drwxrwxr-x 8 thufir thufir   4096 Mar 21 04:15 ./
drwxr-xr-x 8 thufir thufir   4096 Mar 21 04:15 ../
drwxrwxr-x 3 thufir thufir   4096 Mar 21 04:15 gnu/
-rw-rw-r-- 1 thufir thufir 213021 Mar 21 04:15 gnumail-providers.jar
drwxrwxr-x 2 thufir thufir   4096 Mar 21 04:15 lib/
drwxrwxr-x 2 thufir thufir   4096 Mar 21 04:15 META-INF/
drwxrwxr-x 3 thufir thufir   4096 Mar 21 04:15 net/
drwxrwxr-x 9 thufir thufir   4096 Mar 21 04:15 providers/
-rw-rw-r-- 1 thufir thufir   1332 Mar 21 04:15 README.TXT
drwxrwxr-x 2 thufir thufir   4096 Mar 21 04:15 treeutil/
-rw-rw-r-- 1 thufir thufir     70 Mar 21 04:15 usenet.properties
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ 
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ ll META-INF/
total 12
drwxrwxr-x 2 thufir thufir 4096 Mar 21 04:15 ./
drwxrwxr-x 8 thufir thufir 4096 Mar 21 04:15 ../
-rw-rw-r-- 1 thufir thufir  339 Mar 21 04:15 MANIFEST.MF
thufir@dur:~/NetBeansProjects/gnumail-providers/dist$ 

这是对GNU packaging suggestion的回应。

另见:

http://article.gmane.org/gmane.comp.java.netbeans.user/176994

2 个答案:

答案 0 :(得分:6)

右键单击项目/选择“属性”。 在源点头:单击添加文件夹。 在构建节点,Web节点中,选择META-INF ==>单击确定

答案 1 :(得分:1)

如果项目是MAVEN WebApplication,您只需在网页(/ src)中创建结构资源/ META-INF - >主

enter image description here

自动您将在项目中看到“其他来源”文件夹。

enter image description here

您也可以将其应用于其他类型的项目。

希望这个帮助