Double-Clickable Jar File/NetBeans 4.1

Discussion in 'Java' started by Mark H, Jun 29, 2005.

  1. Mark H

    Mark H Guest

    I just got started with NetBeans 4.1 yesterday.

    I want to make a double-clickable jar file, but whenever I try opening
    the .jar in Windows Explorer, I get the error message:

    ====================================
    Java Virtual Machine Launcher
    Could not find the main class. Program will exit!
    ====================================

    I unzipped the jar file to see what was wrong and it looks like
    everything is okay. Here is my ./META-INF/MANIFEST.MF file:

    ====================================
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
    Main-Class: edu.ccp.its.inventory.SwInvMerge
    X-COMMENT: Main-Class will be added automatically by build
    ====================================

    The class file is stored in
    \edu\ccp\its\inventory\SwInvMerge.class

    (Note the Windows path)

    It looks like this should be working but it doesn't. Any thoughts?

    FWIW, I can run the application from NetBeans and from the command line
    just fine. I'm just trying to add the option of double-clicking so that
    user's aren't forced to use the command prompt.

    Thanks, Mark
     
    Mark H, Jun 29, 2005
    #1
    1. Advertising

  2. On 29 Jun 2005 09:31:22 -0700, Mark H wrote:

    > I just got started with NetBeans 4.1 yesterday.


    Oh, the power. (rolls eyes)

    > I want to make a double-clickable jar file,


    So, an application (as opposed to an applet)?

    >.. but whenever I try opening
    > the .jar in Windows Explorer, I get the error message:


    If it is 'double-click' it is an application, IE
    will not open it unless the class with a main()
    is also an applet, and then only in a web page.

    The first thing to figure here is, is this an
    application or an applet (or both).

    [ By the way. I recommend you put aside both NetBeans and
    applets (if that is what you are attempting) for the moment,
    and post messages to a better group for Java beginners -
    comp.lang.java.help ]

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Jun 29, 2005
    #2
    1. Advertising

  3. Mark H wrote:
    > I just got started with NetBeans 4.1 yesterday.
    >
    > I want to make a double-clickable jar file, but whenever I try opening
    > the .jar in Windows Explorer, I get the error message:
    >
    > ====================================
    > Java Virtual Machine Launcher
    > Could not find the main class. Program will exit!
    > ====================================
    >
    > I unzipped the jar file to see what was wrong and it looks like
    > everything is okay. Here is my ./META-INF/MANIFEST.MF file:
    >


    Did you try (in NetBeans) < source packages >< properties >< running
    project > and then setting the main class? (I think you may have
    to "clean" before rebuilding, though.)
     
    Richard F.L.R.Snashall, Jun 29, 2005
    #3
  4. On Wed, 29 Jun 2005 18:38:27 GMT, Andrew Thompson wrote:

    >> the .jar in Windows Explorer, I get the error message:

    >
    > If it is 'double-click' it is an application, IE ...


    ...wait -Windows- Explorer, not -Internet- Explorer.
    Missed that subtle distinction.

    ...but now that I peruse your post much more carefully..

    >> The class file is stored in
    >> \edu\ccp\its\inventory\SwInvMerge.class


    Can you successfully run this class from the command line?
    (No jar)

    ...and does your manifest have a blank line at the end?

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Jun 29, 2005
    #4
  5. Mark H wrote:
    > I just got started with NetBeans 4.1 yesterday.
    >
    > I want to make a double-clickable jar file, but whenever I try opening
    > the .jar in Windows Explorer, I get the error message:
    >
    > ====================================
    > Java Virtual Machine Launcher
    > Could not find the main class. Program will exit!
    > ====================================
    >
    > I unzipped the jar file to see what was wrong and it looks like
    > everything is okay. Here is my ./META-INF/MANIFEST.MF file:
    >
    > ====================================
    > Manifest-Version: 1.0
    > Ant-Version: Apache Ant 1.6.2
    > Created-By: 1.5.0_04-b05 (Sun Microsystems Inc.)
    > Main-Class: edu.ccp.its.inventory.SwInvMerge
    > X-COMMENT: Main-Class will be added automatically by build
    > ====================================
    >
    > The class file is stored in
    > \edu\ccp\its\inventory\SwInvMerge.class
    >
    > (Note the Windows path)
    >
    > It looks like this should be working but it doesn't. Any thoughts?
    >
    > FWIW, I can run the application from NetBeans and from the command line
    > just fine. I'm just trying to add the option of double-clicking so that
    > user's aren't forced to use the command prompt.
    >
    > Thanks, Mark
    >


    Does "java -jar yourjar.jar" work?
    If so you probably have the deafult handler of .jar files wrong.
    It can be set in file-options in explorer.
     
    Tjerk Wolterink, Jun 29, 2005
    #5
  6. Mark H

    Mark H Guest

    Thanks,

    I changed the default handler and now it works smoothly. Does Windows
    usually have the wrong one selected? I'd like for people to be able to
    download my program and run it without having to worry about setting
    the handler.

    Thanks again, Mark
     
    Mark H, Jun 29, 2005
    #6
  7. I would highly, *highly* recommend using Java WebStart then. It
    atomagically handles things like JRE version, creates Star Menu/Desktop
    Icons and makes it much easier to distrubute dependency libraries than
    an executable jar file.

    Mark H wrote:
    > Thanks,
    >
    > I changed the default handler and now it works smoothly. Does Windows
    > usually have the wrong one selected? I'd like for people to be able to
    > download my program and run it without having to worry about setting
    > the handler.
    >
    > Thanks again, Mark
     
    Robert kebernet Cooper, Jun 29, 2005
    #7
  8. On 29 Jun 2005 15:34:53 -0700, Mark H wrote:

    > I changed the default handler and now it works smoothly. Does Windows
    > usually have the wrong one selected?


    No. It works here in Windows Explorer by double clicking the jar.
    (And I did not do anything to set up handlers)

    Note that the top entry on 'open with' is
    Java (TM) 2 Platform Standard Edition Binary

    --
    Andrew Thompson
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.PhySci.org/ Open-source software suite
    http://www.1point1C.org/ Science & Technology
    http://www.LensEscapes.com/ Images that escape the mundane
     
    Andrew Thompson, Jun 30, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Federico
    Replies:
    2
    Views:
    634
    Morten Alver
    Aug 30, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    599
    Arnold Peters
    Jan 5, 2005
  3. muttley
    Replies:
    0
    Views:
    2,755
    muttley
    Oct 20, 2005
  4. Sydex
    Replies:
    12
    Views:
    6,568
    Victor Bazarov
    Feb 17, 2005
  5. Randyl
    Replies:
    1
    Views:
    440
    Andrew Thompson
    Oct 13, 2007
Loading...

Share This Page