Double-Clickable Jar File/NetBeans 4.1

M

Mark H

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
 
A

Andrew Thompson

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 ]
 
R

Richard F.L.R.Snashall

Mark said:
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.)
 
A

Andrew Thompson

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..

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

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

Tjerk Wolterink

Mark said:
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.
 
M

Mark H

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
 
R

Robert kebernet Cooper

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.
 
A

Andrew Thompson

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top