Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Make jar file with dependencies in jBuilder 2007

61 views
Skip to first unread message

Dave

unread,
Mar 28, 2008, 11:01:37 AM3/28/08
to

He,

I used jBuilder 2005 untill now, and after I had a working application, I made a jar file out of it. In 2005 you could go into the properties of the jar file, select "Dependencies" and include all the libraries you used. (all the import-statements in the classes)

Now I use Turbo jBuilder 2007, and I can make a jar file (file - export... - jar-file), but if I use an external library, the jar-file fails. Here's the exceptioin I get : Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/regexp/RE. So the imported library is not found.

I know you could make a reference in the manifest, but it is much better when I can just hand over only a jar-file to my colleagues.
Does anyone has an idea how I can do this in jBuilder2007?


Thanks in advance!

Dave,

Kevin Dean [TeamB]

unread,
Mar 28, 2008, 4:00:18 PM3/28/08
to
Dave wrote:

>Does anyone has an idea how I can do this in jBuilder2007?

The JAR file support in JBuilder 2007 is abysmal and is a common cause for
complaint. Best bet is to create an Ant script and add it as a builder to
the project.

--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

Please see CodeGear's newsgroup guidelines at
http://support.codegear.com/newsgroups/guidelines

Dave

unread,
Mar 31, 2008, 11:03:02 AM3/31/08
to

>>Does anyone has an idea how I can do this in jBuilder2007?
>
>The JAR file support in JBuilder 2007 is abysmal and is a common cause for
>complaint. Best bet is to create an Ant script and add it as a builder to
>the project.

Thanks for your reply! I tried this, but I got the same effect. The jar-file is created, but a methods that depends on an external library, doesn't work. Actually, while running the ant script it does work, but when I double click on the created jar, it doesn't. Do you have any idea what is wrong with this Ant-file?


<project name="T2" basedir="." default="main">

<property name="src.dir" value="src"/>

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

<property name="main-class" value="pac.App2"/>

<property name="lib.dir" value="lib"/>

<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>


<target name="clean">
<delete dir="${build.dir}"/>
</target>

<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>

<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>

<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
</java>
</target>

<target name="clean-build" depends="clean,jar"/>

<target name="main" depends="clean,run"/>

</project>


Thanks a lot!

Kevin Dean [TeamB]

unread,
Apr 3, 2008, 12:51:39 PM4/3/08
to
Dave wrote:

>Thanks for your reply! I tried this, but I got the same effect. The
>jar-file is created, but a methods that depends on an external library,
>doesn't work. Actually, while running the ant script it does work, but
>when I double click on the created jar, it doesn't. Do you have any idea
>what is wrong with this Ant-file?

Hi, sorry for the delay in getting back to you.

What you have there looks like an ANT script exported from JBuilder, which
will do exactly what the JBuilder build would do.

What you need to do is create your own ANT script that will do the
following:

1) create a temporary directory

2) copy your class files to the temporary directory

3) unjar all the dependencies to the temporary directory

4) jar the entire temporary directory

0 new messages