Executable Jar is Not Executable!
It seems like I have tried everything to get this jar to work. My manifest file reads as follows:
Main-Class: Calculator
(extra line)
My main class is Calculator which is in the Calculator package....does this change anything in my manifest? When I double click on the jar it says "Could not find main class" and when I type "java -jar Calculator.jar" at the dos prompt it says "Exception in thread "main" java.lang.NoClassDefFoundError: Calculator/Calculator." I do have a main method in the class. Can anybody get this thing working?
[567 byte] By [
JpS42911] at [2007-9-26 2:50:46]

I think it will work if you add the package name to the Main-Class attribute.
The class name given in Main-Class: Foo<linebreak> must be the full class name - just like when running a "normal" application, java calculator.Calculator.
Well, now I can see why there are so many threads about this, it's quite frustrating.
I've got several packages, and I'm trying to package then all up into an executable jar. Here's the tree structure:
.....\alarmclock\clock\<class and source files>
.....\alarmclock\display\<class and source files>
.....\alarmclock\alarm\<class and source files>
.....\alarmclock\output\<class and source files>
I've also got a file named "manifest.mf" in the directory above the "alarmclock" directory. Here's the text in that file:
Manifest-Version: 1.0
Main-Class: alarmclock.clock.AlarmClock
I execute the jar command thusly from the directory above the "alarmclock" directory:
jar cvmf manifest.mf test.jar alarmclock
But when I type "java -jar test.jar" I get this:
Failed to load Main-Class manifest attribute from test.jar
Any suggestions?
TIA,
Rich
Grrr.
Okay, after mucking about some more and going through the not entirely helpful tutorial yet again, and reading more messages here, I finally figured out that I'm not supposed to add the "Manifest-Version" line in the manifest file, but I AM supposed to add a carriage return after the Main-Class line. So now it works when I type:
java -jar test.jar
But it's still not executable. I get a Windows dialog box title "Program not found," with the text:
Windows cannot find .exe.
This program is needed for opening files of type 'Executable Jar File'.
Then it asks for a location. What file am I missing?
TIA again,
Rich
It looks like .jar files aren't assosiated to the javaw-program. Solution: change the file type settings so that jar files are "opened" in "javaw -jar". The installation program usually does that for you, though...
Argghhh.
Okay, I went to "Start | Settings | Folder Options | File types" and found "Executable Jar File." I modified the "open" action so that that "Application used to perform action" is "c:\jdk1.3.1\bin\javaw -jar". Now when I click on the file I don't get the error. I also don't get the application!
If I change the "javaw.exe" to "java.exe" I get a DOS window momentarily, then it closes and nothing else happens.
Thanks for any assistance,
Rich
This is what it is on my system:C:\Program Files\JavaSoft\JRE\1.3.0_02\bin\javaw.exe -jar %1Maybe you should include the "%1"?
Thanks, JS. There's another thread in the "new to. . ." forum about "making a .class file clickable," and somebody suggested that there. It worked!Rich
> This is what it is on my system:> C:\Program Files\JavaSoft\JRE\1.3.0_02\bin\> javaw.exe -jar %1That won't work. It should be"C:\Program Files\JavaSoft\JRE\1.3.0_02\bin\javaw.exe" -jar "%1"
Well, that's what I see written in the file type list and it does work...
Yes it is in the file type like that but in order to edit it you have to enter it with the quotes arond the path to the javaw then skip quoting the -jar and then quote the %1 in order for windows to be able to find the application
<sarcasm>Really? Are you sure? 100% sure? I never though that M$ windoze could be that stupid...</sarcasm>
The problem is that M$ software is designed for non-technical people, who are ignorant of the problems caused by allowing spaces in filenames.
Just worked with a completely unrelated product on the Spaces in the Path thing...
Windows NT seemed to deal with it, while Windows 98 did not...
It sure is a good thing that MS does such a great job of being compatible with itself.
Unix allows spaces in file names too. That used to be one of my favorite ways to
make a directory that no one could delete... Add an arbitrary number of spaces to
the end of the name.
Hi all,
I have a major doubt in Executabl Jar concept.
When I run a Executable Jar it runs perfectly, question is the classpath option of java command doesn't take any impact.
To be more clear, when I run the below command.
set CPATH=%CLASSPATH%;"d:\sample\classes";
java -jar -cp %CPATH% MyJar.jar
Is there any workaround or clarification for this doubt.
I wonder If I get a solution for this.
Thanks in advance.
The -cp flag does not work with jdk 1.2 and above. But you can use the Class-Path header when constructing your jar file:Class-Path: somefile.jar servlet.jar images/There is more info at this url: http://java.sun.com/docs/books/tutorial/ext/index.html
U can execute without specifying the Mani-Class in the manifest and still execute using the commandjava -classpath Calculator.jar Calculator.Calculatorwill execute the same class if it has a main methodRaghuram
I too had this main class not found problem. My solution was that the jnlp file was incomplete. The error message is so vague you don't know where to start. But check this file line by line for errors.
I had forgotten to put the last quotation mark round the main-class e.g.
<application-desc main-class="robot.Robot/>
instead of
<application-desc main-class="robot.Robot"/>
why not use special .jar tool to help you? [Edited by: jdcforumadmin1 on Jun 24, 2002 1:22 PM]