Archive

Posts Tagged ‘netbeans’

Netbeans 6.8 – Interesting Editor Parsing Bug

29/04/2011 Leave a comment

Do you love the syntax highlighting, code completion and live error reporting too?

That’s why I like NetBeans so much. And in comparison to Eclipse is the work flow a lot better. While I worked at a Java project I got an weird error message (see picture below). I was confused for a while and tried to figure out what exactly the mistake was. Nothing of course, just using a given parameter.

NetBeans editor parsing bug

So I added by copy & paste the line and commented the old one out. And it WORKED! I removed the commented line and could compile the source. I guess it’s a parsing bug by NetBeans, but I wasn’t able to reproduce it…

The same line, but no error...

Very funny story =) I hope you don’t have the same trouble…

Greetz Mavi

Categories: General Tags: , , ,

How to build a single JAR file with external libs

17/08/2010 1 comment

How to combine external libs (.jar files) in an own single JAR file.

If you build a JAR file with NetBeans and your project includes external (or own) compile – time libraries, the final JAR files requires the lib folder with the external JARs in the same directory. For some reasons it’s necessary to have just a single JAR file which everything includes.

Sun (Oracle) describes at  Use NetBeans IDE 6.7 to Combine JAR Files Into a Single JAR File how to do that.

In a nutshell:

Copy following source code into the <project> tag, right before </project> closing tag.

<target name="package-for-store" depends="jar">

        <!-- Change the value of this property to be the name of your JAR,
             minus the .jar extension. It should not have spaces.
             <property name="store.jar.name" value="MyJarName"/>
        -->
        <property name="store.jar.name" value="MarsRoverViewer"/>

        <!-- don't edit below this line -->

        <property name="store.dir" value="store"/>
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

        <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>

        <delete dir="${store.dir}"/>
        <mkdir dir="${store.dir}"/>

        <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
            <zipgroupfileset dir="dist" includes="*.jar"/>
            <zipgroupfileset dir="dist/lib" includes="*.jar"/>

            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>

        <zip destfile="${store.jar}">
            <zipfileset src="${store.dir}/temp_final.jar"
            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
        </zip>

        <delete file="${store.dir}/temp_final.jar"/>

    </target>

Edit the attributes name and value.

<property name="store.jar.name" value="MarsRoverViewer"/>

Run the target as package-for-store and in the project folder a “store” folder appears. You can find the final TAR file in this folder now.

Greetz Mavi

Categories: General Tags: , ,
Follow

Get every new post delivered to your Inbox.