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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:20:50+00:00 2026-06-06T23:20:50+00:00

I have the following directory hierarchy : SigarTest src SigarTest .java files bin SigarTest

  • 0

I have the following directory hierarchy :

SigarTest
 src
    SigarTest
     .java files
 bin
    SigarTest
     .class files

Here,SigarTest is a package name. The root folder is in the bin folder of the jdk.
From there, im running the following command to create a jar file of my project –

./jar cfe temp.jar SigarTest.SigarMain SigarTest/bin/ tools.jar sigar.jar mongo-2.7.3.jar

where tools.jar, mongo-2.7.3.jar and sigar.jar are required and are in the same folder as root directory (bin folder of jdk). However, on running it, i get

ClassNotFoundException : SigarTest.SigarMain

What am i doing wrong ?

  • 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-06T23:20:52+00:00Added an answer on June 6, 2026 at 11:20 pm

    Use the -C dir option which

    Temporarily changes directories (cd dir) during execution of the jar command while processing the following inputfiles argument.

    If you execute the jar command in your question and list the contents of temp.jar, you will see output similar to the following:

    $ rm -rf temp.jar
    $ jar cfe temp.jar SigarTest.SigarMain SigarTest/bin/ tools.jar sigar.jar mongo-2.7.3.jar
    $ jar tf temp.jar
    META-INF/
    META-INF/MANIFEST.MF
    SigarTest/bin/
    SigarTest/bin/SigarTest/
    SigarTest/bin/SigarTest/SigarMain.class
    tools.jar
    sigar.jar
    mongo-2.7.3.jar
    $ java -jar temp.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: SigarTest/SigarMain
    Caused by: java.lang.ClassNotFoundException: SigarTest.SigarMain
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    

    Note that having SigarTest/bin in temp.jar is incorrect. Executing temp.jar throws the ClassNotFoundException since SigarMain is in package SigarTest.bin.SigarTest. Now consider the following jar command that uses the -C dir option:

    $ rm -rf temp.jar
    $ jar cfe temp.jar SigarTest.SigarMain -C SigarTest/bin/ . tools.jar sigar.jar mongo-2.7.3.jar
    $ jar tf temp.jar
    META-INF/
    META-INF/MANIFEST.MF
    SigarTest/
    SigarTest/SigarMain.class
    tools.jar
    sigar.jar
    mongo-2.7.3.jar
    $ java -jar temp.jar
    

    SigarMain is in the correct package and executing temp.jar does not throw a ClassNotFoundException.

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

Sidebar

Related Questions

I have the following directory structure (root) / | \ bin resources src |
I have the following directory structure. root --src ---tests src contains the source &
I have the following directory hierarchy: generated | | -->java Java directory has the
I have the following directory structure of a project: Folder project in Eclipse: --folder
Suppose I have the following directory structure in Vim's NERDTree: /some/folder/ |-apples.txt |-bananas.txt |-
Update : Here is the project. I have the following directory structure: RMI |
I have the following class hierarchy: class A(object): def __init__(self, filename, x): self.x =
I have the following directory structure: folder1/ folder2/ compiler.java For a school assignment, we
I want a Java application to have a directory structure like the following (like
I have the following directory hierarchy -root_folder .htaccess -sub_folder .htaccess The content of the

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.