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.

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="" value="Name of your llibrary"/>
        <property name="version.num" value="1.4.1"/>
            <format pattern="yyyy-MM-dd HH:mm:ss z" property="NOW"></format>

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

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?