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 7670513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:50:23+00:00 2026-05-31T15:50:23+00:00

I have a build.xml file that works fine. The problem is that the generated

  • 0

I have a build.xml file that works fine.
The problem is that the generated jar file, and I need to run it without ‘ant run’

How can I run the jar file?
running with

java -jar Main.jar main.Main 

gives me:

Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/graphdb/GraphDatabaseService

This is how I’m creating the jar file (build.xml):

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

<target name="compile">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.dir}/${conf.dir}"/>
    <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="classpath" includeantruntime="false"/>
    <copy todir="${build.dir}/${conf.dir}">
        <fileset dir="${conf.dir}"/>
    </copy>
</target>

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

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

The “ant run” task works fine with this jar.
How can I run this project without ant?

  • 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-31T15:50:24+00:00Added an answer on May 31, 2026 at 3:50 pm

    Use java -cp Main.jar main.Main, -jar is for bundled jars with a Manifest saying which class is to be used as the main class. What you’re doing with -cp (and within your ant build file) is just putting it on the main path: you’re specifying main.Main as the main class explicitly, not within a manifest.

    You should also put the other jars on the classpath (e.g. -cp lib/example1.jar:lib/example2.jar:Main.jar). Depending on what matches **/*.jar, there may be a number of them.

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

Sidebar

Related Questions

I have an object that can build itself from an XML string, and write
I have an ant build.xml file with XJC task definition: <taskdef name=xjc classname=com.sun.tools.xjc.XJCTask> <classpath>
I have a build.xml that work fine, until I start using boilerplate generation and
Let's say I have a file-system that looks a little something like this: C:\stuff\build.xml
I have the following defined in a file called build-dependencies.xml <?xml version=1.0 encoding=UTF-8?> <project
I have the following build.xml file setup in phpUnderControl. <target name=phpunit> <exec executable=phpunit dir=${basedir}/httpdocs
I have a process that parses an XML file using JDOM and xpath to
I have an exiting ant build that is called via ant -lib lib -f
I have an XML file (urlrewrite.xml) that needs a property placeholder resolved. I enable
Do you have some predefined set of targets which all build.xml files you create

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.