Re: Jar files from command line
Bill wrote:
I'm trying to run an app from a jar file at command line,
These are the lines in the .java file where I see the entry point
for my app in the jar file, LottoMadness.jar, that I created:
public class LottoMadness extends JFrame {
LottoEvent lotto = new LottoEvent(this);
With this, the line in the manifest.txt should read:
Main-Class: javax.swing.LottoMadness
right? as "MyPackage.MyClass" is the example I've read from Sun.
Nope. I don't see a "main" method in LottoMadness there. Making a new
LottoEvent has nothing to do with starting Java. Please show us
something relevant to the problem.
I keep trying to run command java -jar LottoMadness.jar, but I get
"Failed to load Main-Class manifest attribute frm LottoMadness.jar"
The app.runs from java LottoMadness command, but I can't get the
jar setup right. I've been using the
http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
Well, your links have improved.
On that page you linked to, it describes how to set the main class
attribute with the jar command. Have you tried that? Can you show us
the commands you used and the MANIFEST file inside your jar? The error
message you quote above tells us nothing, other than your MANIFEST file
is messed up.
Here's the quote from the page you link to:
Setting an Entry Point with the JAR Tool
The 'e' flag (for 'entrypoint'), introduced in JDK 6, creates or
overrides the manifest's Main-Class attribute. It can be used while
creating or updating a jar file. Use it to specify the application entry
point without editing or creating the manifest file.
For example, this command creates app.jar where the Main-Class
attribute value in the manifest is set to MyApp:
jar cfe app.jar MyApp MyApp.class
You can directly invoke this application by running the following
command:
java -jar app.jar