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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:55:35+00:00 2026-06-14T12:55:35+00:00

I created two jar files, my.common.jar which contain helper classes and methods (mostly static

  • 0

I created two jar files, my.common.jar which contain helper classes and methods (mostly static methods). I also created a jar file, test.jar with a main method that calls a static method in a class in my.common.jar.

Everything works fine when I launch main like this:

java -classpath path/to/myjars/my.common.jar:./test.jar test.Tester

Tester is the class in test.jar that contains method main.

But I get NoClassDefFoundError my/common/Myclass when I run it this way:

java -classpath path/to/myjars/my.common.jar -jar test.jar

I tried so hard, but I am not able to figure out why it fails or how to resolve this issue. I do appreciate your help.

—– addendum —-
I forgot to mention that the manifest file in test.jar looks like so:

    Manifest-Version: 1.0
    Build-Jdk: 1.6.0_13
    Created-By: Apache Maven
    Main-Class: test.Tester
    Archiver-Version: Plexus Archiver
  • 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-14T12:55:36+00:00Added an answer on June 14, 2026 at 12:55 pm

    You cannot use both -classpath and -jar options on the command line. Use one or the other … but not both.

    When you use the -jar option, the command expects to find the entry point class AND the runtime classpath in the JAR file manifest. Your -classpath argument will be ignored, as will the CLASSPATH environment variable. To quote from the java manual page:

    “When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.”

    If your (executable) JAR file needs to use things in other JARs, then it need a Class-Path attribute in the manifest. This attributes value is a space separated list of URLs; see here.

    So in your case, you would need to add something like this to your JAR’s manifest:

    Class-path: /path/to/myjars/my.common.jar
    

    This page of the Java Tutorial covers this topic, and includes the warning that the Class-path manifest line must be properly terminated with a CR or NL for the JVM to recognize it.

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

Sidebar

Related Questions

I found a Client.jar file on a customer's computer, containing two .class files which
I have two classes. I created a JAR file using: jar cvf practice.jar class1.class
I created two files in the App_GlobalResources folder: SiteResources.en-US.resx SiteResources.sp-SP.resx Both contain a value
I created two classes in netbeans;One of them is a JPanel form and another
I created two very simple Heroku apps to test out the service, but it's
I created a JApplet which uses two external libraries ( JENA and JUNG ).
I have two .jar files having same package structure and same class name. Eg.
Basically, I created a build.xml for Apache Ant. I use all the .jar files
I'm bundling ttf files in a jar file and intend to use them as
I created two dropdpwn calendar in my form with these codes: <script type=text/javascript src=http://code.jquery.com/jquery-latest.js></script>

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.