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

The Archive Base Latest Questions

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

So I made this (very simple) program with a swing GUI with NetBeans, and

  • 0

So I made this (very simple) program with a swing GUI with NetBeans, and I clicked build to make a jar file. When I run it by double clicking it, it tells me it could not find the main class, which, after checking, I am sure is definitely there. But, when I run it from Command Prompt, it works perfectly. Any easily-determinable reason for this strange behaviour (if you want the source code, I can post it here)?

  • 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-06T01:20:35+00:00Added an answer on June 6, 2026 at 1:20 am

    The things that seem to be needed in NetBeans are:

    • The project has to be the Main Project (by right clicking on it in the Projects list).
    • You have to set the Main Class in the project properties. (Right click, Properties, Run, Main Class.)

    Then when you right click on your project and do a “Clean and Build”, a jar will get built into the dist subdirectory.

    If that fails to fix the problem, here’s a longer story…

    When you double click a jar file to run it, the operating system acts as if you had typed this from the command line:

    java -jar filename.jar
    

    (When you say it works for you from the command line, is this what you’re typing?)

    At that point, the Java executable looks for a file inside the jar named META-INF/MANIFEST.MF. And then in the contents of that file, it looks for the value of a property, Main-Class. And finally it looks for the class of that name in your jar and runs its static main(String[]) method.

    So if your jar is failing to run, you can do the following to debug what’s going on:

    • Clean and rebuild your project in NetBeans.
    • Double check that your class(es) are actually in the jar:
      • Start a command prompt
      • cd into the dist subdirectory of your project.
      • Use a command like jar tf filename.jar to list what’s in there.
    • Double check that the MANIFEST.MF file is correct:
      • Again in a command prompt
      • cd into the dist directory.
      • Use a command like jar xf filename.jar META-INF/MANIFEST.MF to extract the manifest.
      • Look at the contents of that file (e.g. type META-INF\MANIFEST.MF) and make sure Main-Class is set to the appropriate class.

    If all of the above check out, then double clicking the file should work.

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

Sidebar

Related Questions

So I made a very simple program that counts down from 99 (sings 99
I made this very simple 3D model exported to .x format with Google SketchUp,
I have a very simple openGL program in C++. I have made a Sphere
I'm unable to build a very simple program when building for the iPhone simulator.
I recently made a very simple practice program in Python, that takes user input
I made a a simple GUI program in python with tkinter and attempted to
I made this simple function to filter the data. I add the symbols that
I made this program for a school, and it involves a telnet server. When
I decided to implement a very simple program recursively, to see how well Java
I am a rather new C++ programmer. I have made a very simple game

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.