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

  • Home
  • SEARCH
  • 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 7001953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:52:04+00:00 2026-05-27T20:52:04+00:00

I have a project set up like this; Project -src -com -top -classes Class_3.java

  • 0

I have a project set up like this;

Project
    -src
        -com
            -top
                -classes
                    Class_3.java
                    Class_4.java
                -utils
                    Class_5.java
                    Class_6.java
                Class_1.java
                Class_2.java
    -data
        various files
    -libs
        lib_1.jar
        lib_2.jar
        lib_3.jar
        lib_4.jar
    build.xml

class_1.java contains the main class, libs contains external dependencies, data contains various images, text files etc…

I have been trying to write an Ant build file to make a distributable JAR file but am having difficultied pulling in all the required libraries etc…

This is where I am up to.

<?xml version="1.0"?>
<project name="Project" default="jar">

    <property name="libsSrc" value="libs"/>
    <property name="build" value="build"/>
    <property name="classes" value="build/classes"/>
    <property name="jar" value="build/jar"/>
    <property name="libs" value="build/libs"/>

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

    <target name="clean" description="remove intermediate files">
        <delete dir="build"/>
    </target>

    <target name="compile" description="compile the Java source code to class files">
        <mkdir dir="${classes}"/>
        <javac srcdir="." destdir="${classes}" classpathref="classpath">
            <compilerarg line="-encoding utf-8"/>
        </javac>
    </target>

    <target name="jar" depends="compile" description="create a Jar file for the application">
        <mkdir dir="${jar}"/>
        <jar destfile="${jar}/App.jar">
            <fileset dir="${classes}" includes="**/*.class"/>
            <manifest>
                <attribute name="Main-Class" value="com.top.Class_1"/>
            </manifest>
        </jar>
    </target>

</project>

This doesn’t work currently.

It compiles with no errors but doesn’t include the required dependencies and the JAR cannot find the main class. How can I fix it?

  • 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-27T20:52:05+00:00Added an answer on May 27, 2026 at 8:52 pm
    <?xml version="1.0"?>
    <project name="Rutherford" default="jar">
    
        <property name="libsSrc" value="libs"/>
        <property name="build" value="build"/>
        <property name="classes" value="build/classes"/>
        <property name="jar" value="build/jar"/>
        <property name="libs" value="build/libs"/>
    
        <path id="classpath">
                <fileset dir="${libsSrc}" includes="*.jar"/>
        </path>
    
        <pathconvert property="mf.classpath" pathsep=" ">
                <path refid="classpath"/>
                <mapper>
                        <chainedmapper>
                                <flattenmapper/>
                                <globmapper from="*.jar" to="lib/*.jar"/>
                        </chainedmapper>
                </mapper>
        </pathconvert>
    
        <target name="clean" description="remove intermediate files">
            <delete dir="build"/>
        </target>
    
        <target name="compile" description="compile the Java source code to class files">
            <mkdir dir="${classes}"/>
            <javac srcdir="." destdir="${classes}" classpathref="classpath">
                <compilerarg line="-encoding utf-8"/>
            </javac>
        </target>
    
        <target name="jar" depends="compile" description="create a Jar file for the application">
            <mkdir dir="${jar}"/>
            <jar destfile="${jar}/App.jar">
                <zipgroupfileset dir="${libsSrc}" includes="*.jar"/>
                <fileset dir="${classes}" includes="**/*.class"/>
                <manifest>
                    <attribute name="Main-Class" value="com.top.Class_1"/>
                    <attribute name="Class-Path" value="${mf.classpath}"/>
                </manifest>
            </jar>
        </target>
    
    </project>
    

    Seems to do the trick but the line;

    <compilerarg line="-encoding utf-8"/>
    

    seems to do nothing, I have a few text files containing UTF-8 encoded characters that are read into strings and displayed that are not showing properly; dσ/dΩ shows as dÃ/d©. I will ask that in another question though.

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

Sidebar

Related Questions

I have got a question regarding suprepositories. Our project is set up like this:
I have just set up a new Eclipse Java project. In this project I
We have an old project that is set up like this: . ├── customizationProject
If I have a folder structure set up like this: ~/Projects emacs package1 package1-helpers
Currently I have a root-level repository set up for each project, like so: Project1
I have a NetBeans project set up with a bunch of source classes and
For educational purposes I have set up a project layout like so (flat in
I have a file structure that looks something like this: project1_root/ tests/ ... src/
in my project i have a requirement like Set the version to something like
We'd like to set up our SBT project so that we have multiple test

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.