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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:13:52+00:00 2026-06-11T13:13:52+00:00

I am trying to create a jar file that is self contained concerning the

  • 0

I am trying to create a jar file that is “self contained” concerning the libraries it needs.

Therefore, I created the following ant file:

<project name="srv" default="prod">
    <target name="prod">
        <jar destfile="build/ServerApplication.jar" basedir="bin/">
            <restrict>
             <name name="**/*.class"/>
             <archives>
               <zips>
                 <fileset dir="lib/" includes="**/*.jar"/>
               </zips>
             </archives>
            </restrict>
            <manifest>
                <attribute name="Class-Path" value="." />
                <attribute name="Main-Class" value="my.package.ServerApplication" />
            </manifest>
        </jar>
    </target>
</project>

But, when I try to launch the application using

> java -jar ServerApplication.jar

I get an error

No suitable driver found for jdbc:mysql://localhost/db?user=root&password=

I reckon this is because the com.mysql.jdbc package inside the jar can’t be found. Why is this? When I set the Class-Path to ., shouldn’t the jar be able to find all classes inside that jar?

I opened the jar in a decompiler, and all the classes are where they need to be, see here:

Decompiled JAR

What is going wrong here? My MANIFEST looks like this:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.7.0_07-b10 (Oracle Corporation)
Main-Class: my.package.ServerApplication
Class-Path: .
  • 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-06-11T13:13:53+00:00Added an answer on June 11, 2026 at 1:13 pm

    You must explicitly write the names of the jars if you want them included separated by spaces. Otherwise I would recommend simply launching your jar and providing the class path as a parameter manually:

    java -cp . -jar ServerApplication.jar
    

    See here for more information.

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

Sidebar

Related Questions

I'm trying to use Maven to create an executable jar file that includes the
I am trying to create a standalone jar file I don't think that maven
I am trying to create an OSGi service that wraps another jar. I added
I have a single .jar file that I create by using the runnable .jar
I am trying to read database scripts in a Jar file so that I
I'm trying to create a distributable zip of my project that contains several configuration
I'm trying to create an Android library JAR and would like to use ant
I am trying to create a Worker Role project for Windows Azure that loads
I'm trying to create a small application that will copy some .jar files into
I have a NetBeans project that I'm trying to compile manually from command-line ant

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.