Showing posts with label Netbeans. Show all posts

How to create resource folder in Netbeans?

What is resource folder?
Resource folder is same as src folder of project. However it aimed to store .ico, .mp3, .xml, .properties, etc… files of Project. These are common files used in project.

Note: On successful compilation of project all resource file will be stored in bin folder of project with same structure of resource folder.

Step 1: Right click on Project and go to Properties.


Step 2: Go to Sources and click on Add Folder...


Step 3: Create folder called resources by clicking on icon at top right corner then click on Open.
Note: You can give any name to resources. Its not compulsory to give folder name resources.


Step 4: Click Ok on Project Properties window.

Step 5: You successfully created resource folder in Netbeans and now you can add common files in it.


References
How to read Properties file from resource folder in Java?

How to attach MANIFEST.MF file in jar in/using Netbeans?


Step 1: Open build.xml file in notepad or other editor and paste below code within <project>...</project>
<target name="-pre-init">
        <property name="project.name" value="Name of your llibrary"/>
        <property name="version.num" value="1.4.1"/>
        <tstamp>
            <format pattern="yyyy-MM-dd HH:mm:ss z" property="NOW"></format>
        </tstamp>

    <!--
    <exec outputproperty="svna.version" executable="svnversion">
     <arg value="-c" />
     <redirector>
      <outputfilterchain>
       <tokenfilter>
        <replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
        <replaceregex pattern="M" replace="" flags="g"/>
       </tokenfilter>
      </outputfilterchain>
     </redirector>
    </exec>
    -->
        <manifest file="MANIFEST.MF">
            <attribute name="Codebase" value="*"/>           
            <attribute name="Permission" value="all-permissions"/>
            <attribute name="Application-Library-Allowable-Codebase" value="javaquery.com"/>
            <attribute name="Caller-Allowable-Codebase" value="www.javaquery.com javaquery.com"/>
            <attribute name="Application-Name" value="javaQuery"/>
            <attribute name="Bundle-Name" value="${project.name}"/>           
            <attribute name="Bundle-Version" value="${version.num}"/>
            <attribute name="Bundle-Date" value="${NOW}"/>
            <attribute name="Implementation-Title" value="${project.name}"/>
            <attribute name="Implementation-Version" value="${version.num}"/>
            <attribute name="Implementation-URL" value="http://www.javaquery.com"/>
            <!--<attribute name="Bundle-Revision" value="${svna.version}" />-->
        </manifest>
 </target>

Step 2: Edit your required details in attributes. Uncomment the SVN version code if you want to put SVN version details in MANIFEST.MF file

Step 3: Save build.xml file

Step 4: Set your project as main project in netbeans. Now Go to RUN > Clean and build main project

Step 5: Find your output jar file in dist folder of project.

Other Resources:
How to attach MANIFEST.MF file in jar in/using eclipse?
How to create .jar file in netbeans?