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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:15:42+00:00 2026-06-15T11:15:42+00:00

My directory structure is like this: > makefile > app.jar > src > Main.java

  • 0

My directory structure is like this:

> makefile
> app.jar
> src
    > Main.java
    > Main.class
    > some other classes
    > manifest.txt

I compile from the makefile with these commands:

javac src/*.java
jar cvfm app.jar src/manifest.txt src/*.class

manifest.txt contains this:

Main-Class: Main

When I run java -jar app.jar from the top directory I get this error:

$ java -jar app.jar 
Exception in thread "main" java.lang.NoClassDefFoundError: Main
Caused by: java.lang.ClassNotFoundException: Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    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: Main. Program will exit.

I tried changing the manifest to say Main-Class: src.Main but that didn’t work either. This is probably very simple but I’m finding Google doesn’t provide any simple solutions.

  • 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-15T11:15:43+00:00Added an answer on June 15, 2026 at 11:15 am

    Please find the answer from Oracle

    http://docs.oracle.com/javase/tutorial/deployment/jar/build.html

    Please find the sample code:-

    package oata
    public class HelloWorld {
     public static void main(String[] args) {
        System.out.println("Hello World");
     }
     }
    

    Create a folder to place the .class file
    Then compile the and run the file.

     `md build\classes
       javac -sourcepath src -d build\classes src\oata\HelloWorld.java
      java -cp build\classes oata.HelloWorld`
    
    
      `echo Main-Class: oata.HelloWorld>myManifest
         md build\jar
        jar cfm build\jar\HelloWorld.jar myManifest -C build\classes .
        java -jar build\jar\HelloWorld.jar`
    

    Thanks
    Pavan

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

Sidebar

Related Questions

This is annoying. I have a directory structure like this -lib --some jar files
I have directory structure like this src main resources text.txt scala hello world.scala test
I have a directory structure like this client/lib a.jar b-4.3.jar c-1.2.jar d-4.3.jar e.jar I
I have a directory structure like this: .git/ .gitignore main/ ... tools/ ... ...
For example, I have a directory structure like this: my_stuff classes one two more
If I have a directory structure like this: package/ __init__.py functions.py #contains do() classes.py
I have a directory structure like this: ./ +-- myClass | +-- MainClass.class |
My Question Suppose I have a directory structure like this: app/ core/ bin/ runner
I have an Xcode project with a directory structure like this: MasterProjectDir/projectname.xcodeproj MasterProjectDir/ProjectSubDir/whatever.c MasterProjectDir/ProjectSubDir/etc.c
I am a beginner in SVN.I have the SVN directory structure like this: |-trunk

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.