Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:14:46+00:00 2026-05-17T00:14:46+00:00

I have just ‘inherited’ a Java-project and not coming from a Java-background I am

  • 0

I have just ‘inherited’ a Java-project and not coming from a Java-background I am a little lost at times. Eclipse is used to debug and run the application during development. I have through Eclipse succeeded in creating a .jar-file that ‘includes’ all the required external jars like Log4J, xmlrpc-server, etc. This big .jar can then be run successfully using:

java -jar myjar.jar

My next step is to automate builds using Ant (version 1.7.1) so I don’t have to involve Eclipse to do builds and deployment. This has proven to be a challenge due to my lacking java-knowledge. The root of the project looks like this:

|-> jars (where external jars have been placed)
|-> java
| |-> bin (where the finished .class / .jars are placed)
| |-> src (Where code lives)
| |-> ++files like build.xml etc
|-> sql (you guessed it; sql! )

My build.xml contains the following:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="Seraph">
    <property environment="env"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.6"/>
    <property name="source" value="1.6"/>

    <property name="build.dir"     value="bin"/>
    <property name="src.dir"       value="src"/>
    <property name="lib.dir"       value="../jars"/>
    <property name="classes.dir"   value="${build.dir}/classes"/>
    <property name="jar.dir"       value="${build.dir}/jar"/>
    <property name="jar.file"      value="${jar.dir}/seraph.jar"/>
    <property name="manifest.file" value="${jar.dir}/MANIFEST.MF"/>

    <property name="main.class" value="no.easyconnect.seraph.core.SeraphCore"/>

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

    <path id="project.classpath">
        <pathelement location="${src.dir}"/>
        <path refid="external.jars" />
    </path>

    <target name="init">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${classes.dir}"/>
        <mkdir dir="${jar.dir}"/>
        <copy includeemptydirs="false" todir="${build.dir}">
            <fileset dir="${src.dir}">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

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

    <target name="cleanall" depends="clean"/>

    <target name="build" depends="init">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}" classpathref="project.classpath">
            <src path="${src.dir}"/>
        </javac>
    </target>

    <target name="build-jar" depends="build">
        <delete file="${jar.file}" />
        <delete file="${manifest.file}" />

        <manifest file="${manifest.file}" >
            <attribute name="built-by" value="${user.name}" />
            <attribute name="Main-Class" value="${main.class}" />
        </manifest>

        <jar destfile="${jar.file}" 
            basedir="${build.dir}" 
            manifest="${manifest.file}">
            <fileset dir="${classes.dir}" includes="**/*.class" />
            <fileset dir="${lib.dir}" includes="**/*.jar" />
        </jar>
    </target>
</project>

I then run:
ant clean build-jar

and a file named seraph.jar is placed in the java/bin/jar-directory. I then try to run this jar using the following command:
java -jar bin/jar/seraph.jar

The result is this output at the console:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at no.easyconnect.seraph.core.SeraphCore.<clinit>(SeraphCore.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 1 more
Could not find the main class: no.easyconnect.seraph.core.SeraphCore. Program will exit.

I suspect that I have done something amazingly silly in the build.xml-file and have spent the better part of two days trying variations on the configuration, to no avail. Any help on getting this working is greatly appreciated.

Oh, and I’m sorry if I left some crucial information out. This is my first time posting here at SO.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:14:46+00:00Added an answer on May 17, 2026 at 12:14 am

    With the helpful advice from people who have answered here I started digging into One-Jar. After some dead-ends (and some results that were exactly like my previous results I managed to get it working. For other peoples reference I’m listing the build.xml that worked for me.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <project basedir="." default="build" name="<INSERT_PROJECT_NAME_HERE>">
        <property environment="env"/>
        <property name="debuglevel" value="source,lines,vars"/>
        <property name="target" value="1.6"/>
        <property name="source" value="1.6"/>
    
        <property name="one-jar.dist.dir" value="../onejar"/>
        <import file="${one-jar.dist.dir}/one-jar-ant-task.xml" optional="true" />
    
        <property name="src.dir"          value="src"/>
        <property name="bin.dir"          value="bin"/>
        <property name="build.dir"        value="build"/>
        <property name="classes.dir"      value="${build.dir}/classes"/>
        <property name="jar.target.dir"   value="${build.dir}/jars"/>
        <property name="external.lib.dir" value="../jars"/>
        <property name="final.jar"        value="${bin.dir}/<INSERT_NAME_OF_FINAL_JAR_HERE>"/>
    
        <property name="main.class"       value="<INSERT_MAIN_CLASS_HERE>"/>
    
        <path id="project.classpath">
            <fileset dir="${external.lib.dir}">
                <include name="*.jar"/>
            </fileset>
        </path>
    
        <target name="init">
            <mkdir dir="${bin.dir}"/>
            <mkdir dir="${build.dir}"/>
            <mkdir dir="${classes.dir}"/>
            <mkdir dir="${jar.target.dir}"/>
            <copy includeemptydirs="false" todir="${classes.dir}">
                <fileset dir="${src.dir}">
                    <exclude name="**/*.launch"/>
                    <exclude name="**/*.java"/>
                </fileset>
            </copy>
        </target>
    
        <target name="clean">
            <delete dir="${build.dir}"/>
            <delete dir="${bin.dir}"/>
        </target>
    
        <target name="cleanall" depends="clean"/>
    
        <target name="build" depends="init">
            <echo message="${ant.project.name}: ${ant.file}"/>
            <javac debug="true" debuglevel="${debuglevel}" destdir="${classes.dir}" source="${source}" target="${target}">
                <src path="${src.dir}"/>
                <classpath refid="project.classpath"/>   
            </javac>
        </target>
    
        <target name="build-jar" depends="build">
            <delete file="${final.jar}" />
            <one-jar destfile="${final.jar}" onejarmainclass="${main.class}">
                <main>
                    <fileset dir="${classes.dir}"/>
                </main>
                <lib>
                    <fileset dir="${external.lib.dir}" />
                </lib>
            </one-jar>
        </target>
    </project>
    

    I hope someone else can benefit from this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to use Eclipse for my Java programmaing. I just wonder
we have just started using a git account of our Django website project so
I have just installed composer in my /usr/bin folder, so when from that folder
I have just started implementing ISet 's instead of IList 's in my project
I have just started leaning and working on xquery with java. I have a
We have just migrated from solr3.5 to solr3.6, for all this time we have
I have just discovered the command :sort n in vim (how did I not
I have just changed from Ninject to TinyIoC for dependency injection and I'm having
I have just created a new MVC 3 project and updated all the installed
Have just written a small app to read from our MSMQ dead letter queue,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.