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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:19:03+00:00 2026-05-25T10:19:03+00:00

I have to create a JAR file (without using any IDE) That’s what I’m

  • 0

I have to create a JAR file (without using any IDE)

That’s what I’m doing:

I got a folder named Project, this is the main one, in this one i two folders and a pdf file.

one named ClassFiles that contains all the “.class” files of my project

the other one named JavaFiles that contains all the “.java” files.

the file is a relation that i have to include, nothing relevant though, and is called Info.pdf.

The error i have is this:

My main class (is redundant, i mean the starting one, with “public static void main(String[] args)”) is called Main

the command line i’m using is:

jar -cfe Project.jar ClassFiles.Main JavaFiles ClassFiles INFO.pdf

i get the error Could not find the main class: ClassFiles.Main. Program will exit

PS: in the ClassFiles folder i have a lot of classname$1, classname$2 files. i don’t know if it’s relevant. I even have the Main with and another Main$1.

I need to give this JAR tomorrow, so i’m quite desperate.

Thank you in advance!

Exception in thread "main" java.lang.NoClassDefFoundError: ClassFiles/Main (wrong name: Main)

    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: ClassFiles.Main. Program will exit

@erikson:
ClassFiles is just a folder i made to contain all the .class, nothing more… there is no package in what i did (it was the default one when i used Eclipse)

@ Dave Newton: sorry man, (first of all thank you), could u be a little more specific? i’m not understanding what i should do. i’m not really good with this stuff

ah, if you mean that the package is not called Project but Progetto is just becouse i translated it in english. not sure if that’s what you are referring too.

I have the Main.class in the ClassFiles directory and Main.java in the JavaFiles dir

That’s exactly what i did and the result:

ascal@AscaL ~/Desktop/Progetto $ jar -cfe Progetto.jar ClassFiles.Main ClassFiles JavaFiles Info.pdf

ascal@AscaL ~/Desktop/Progetto $ java -jar Progetto.jar

Exception in thread “main” java.lang.NoClassDefFoundError: ClassFiles/Main (wrong name: Main)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Could not find the main class: ClassFiles.Main. Program will exit.

//Code of Main.java

http://pastebin.com/Xh9emcYH

  • 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-25T10:19:03+00:00Added an answer on May 25, 2026 at 10:19 am

    You get that error when you run the jar command? Works fine for me.

    $ tree
    .
    ├── ClassFiles
    │   └── Main.class
    ├── JavaFiles
    │   └── Main.java
    └── Project.jar
    $ jar -cfe Project.jar ClassFiles.Main JavaFiles ClassFiles
    $ jar -tf Project.jar
    META-INF/
    META-INF/MANIFEST.MF
    JavaFiles/
    JavaFiles/Main.java
    ClassFiles/
    ClassFiles/Main.class
    

    Of course, if you run it via java -jar Project.jar, and the Main class isn’t in the ClassFiles package, it’ll break. What package is the Main class in?

    $ cat META-INF/MANIFEST.MF 
    Manifest-Version: 1.0
    Created-By: 1.6.0_26 (Apple Inc.)
    Main-Class: ClassFiles.Main
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a .jar file that I have created using either
Is it possible to create a JAR file that requires external dependencies without including
I am trying to create and use jar file in an Android project under
I have created a JAR file in this way jar cf jar-file input-files .
I have created a java application and packed it into a jar file on
I have create my own NSOpenGLView class, right now the data that i want
I have to create a site definition for a client that must contain pre-defined
Is is mandatory to have classpath inside a Manifest file inside the java jar
I'm a .Net developer, but for my current project I have to create some
I'm trying to parse some JSON object strings that I'm getting using gson-1.6.jar I

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.