You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ir...@t-systems.com on 2008/06/18 09:25:42 UTC

unable to execute JAR file

Hi All,

 

I have 10 java files and I have written Ant build.xml to compile and
create JAR file which contains the .class files. Now my requirement is
that I need to execute/install the JAR file but unfortunately I can't do
this as I am getting following error.

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar
test.jar

Failed to load Main-Class manifest attribute from

test.jar

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>

 

Please find the attached java code and build script.

 

Please help

 

Regards

Irfan.

 


Re: unable to execute JAR file

Posted by Prashant Reddy <pr...@pramati.com>.
Google is your friend.

http://www.google.co.in/search?q=Failed+to+load+Main-Class+manifest+attribute

The first hit from the search result has this link to Java tutorial :
http://java.sun.com/docs/books/tutorial/deployment/jar/basicsindex.html

To execute a jar using 'java' command, the JAR file needs to have a 
MANIFEST.MF file with entry 'Main-Class'.

The value of this entry must be the fully qualified class name which has 
the main() function.

-Prashant

Irfan.Sayed@t-systems.com wrote:
>
> Hi All,
>
> I have 10 java files and I have written Ant build.xml to compile and 
> create JAR file which contains the .class files. Now my requirement is 
> that I need to execute/install the JAR file but unfortunately I can’t 
> do this as I am getting following error.
>
> D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar 
> test.jar
>
> Failed to load Main-Class manifest attribute from
>
> test.jar
>
> D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>
>
> Please find the attached java code and build script.
>
> Please help
>
> Regards
>
> Irfan.
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: unable to execute JAR file

Posted by Ognjen Blagojevic <og...@rcub.bg.ac.yu>.
Irfan.Sayed@t-systems.com wrote:
> I have 10 java files and I have written Ant build.xml to compile and 
> create JAR file which contains the .class files. Now my requirement is 
> that I need to execute/install the JAR file but unfortunately I can’t do 
> this as I am getting following error.
...
> Failed to load Main-Class manifest attribute from

You should read a bit about manifest files. See this link[1].

In short, JVM doesn't know which class has the main method to be used as 
the entry point to your application.

-Ognjen

[1] 
http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: unable to execute JAR file

Posted by Ir...@t-systems.com.
Thanks for all reply.

Now what I did is I compiled only one source file and made a jar out of
it which contains only one ArrayExample.class file. Once JAR available
then I unzipped that JAR and edited the manifest file as per your
suggestion but still I am getting same error.

Please find the attached java source file and manifest file.

Please help

Regards
Irfan.

-----Original Message-----
From: Taj, Abdul [mailto:abdul_taj@mcgraw-hill.com] 
Sent: Wednesday, June 18, 2008 6:23 PM
To: Ant Users List
Subject: RE: unable to execute JAR file

Does the jar have a manifest file that specifies the main class that
needs to be executed when you execute it?

 

When you create a jar it will have a META-INF directory inside which you
need to place a manifest file that has the main class that needs to be
executed when you execute the jar file. 

 

Just google about the manifest file and you will get your answer

 

-t

 

 

________________________________

From: Irfan.Sayed@t-systems.com [mailto:Irfan.Sayed@t-systems.com] 
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@ant.apache.org
Subject: unable to execute JAR file

 

Hi All,

 

I have 10 java files and I have written Ant build.xml to compile and
create JAR file which contains the .class files. Now my requirement is
that I need to execute/install the JAR file but unfortunately I can't do
this as I am getting following error.

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar
test.jar

Failed to load Main-Class manifest attribute from

test.jar

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>

 

Please find the attached java code and build script.

 

Please help

 

Regards

Irfan.
--------------------------------------------------------

The information contained in this message is intended only for the
recipient, and may be a confidential attorney-client communication or
may otherwise be privileged and confidential and protected from
disclosure. If the reader of this message is not the intended recipient,
or an employee or agent responsible for delivering this message to the
intended recipient, please be aware that any dissemination or copying of
this communication is strictly prohibited. If you have received this
communication in error, please immediately notify us by replying to the
message and deleting it from your computer.  The McGraw-Hill Companies,
Inc. reserves the right, subject to applicable local law, to monitor and
review the content of any electronic message or information sent to or
from McGraw-Hill employee e-mail addresses without informing the sender
or recipient of the message.
--------------------------------------------------------


RE: unable to execute JAR file

Posted by "Taj, Abdul" <ab...@mcgraw-hill.com>.
Does the jar have a manifest file that specifies the main class that
needs to be executed when you execute it?

 

When you create a jar it will have a META-INF directory inside which you
need to place a manifest file that has the main class that needs to be
executed when you execute the jar file. 

 

Just google about the manifest file and you will get your answer

 

-t

 

 

________________________________

From: Irfan.Sayed@t-systems.com [mailto:Irfan.Sayed@t-systems.com] 
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@ant.apache.org
Subject: unable to execute JAR file

 

Hi All,

 

I have 10 java files and I have written Ant build.xml to compile and
create JAR file which contains the .class files. Now my requirement is
that I need to execute/install the JAR file but unfortunately I can't do
this as I am getting following error.

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar
test.jar

Failed to load Main-Class manifest attribute from

test.jar

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>

 

Please find the attached java code and build script.

 

Please help

 

Regards

Irfan.
--------------------------------------------------------

The information contained in this message is intended only for the recipient, and may be a confidential attorney-client communication or may otherwise be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, please be aware that any dissemination or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by replying to the message and deleting it from your computer.  The McGraw-Hill Companies, Inc. reserves the right, subject to applicable local law, to monitor and review the content of any electronic message or information sent to or from McGraw-Hill employee e-mail addresses without informing the sender or recipient of the message.
--------------------------------------------------------

Re: unable to execute JAR file

Posted by Henning Bredel <h....@gmx.de>.
On Wednesday 18 June 2008 09:25:42 Irfan.Sayed@t-systems.com wrote:
> Hi All,
>
>
>
> I have 10 java files and I have written Ant build.xml to compile and
> create JAR file which contains the .class files. Now my requirement is
> that I need to execute/install the JAR file but unfortunately I can't do
> this as I am getting following error.
>
>
>
> D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar
> test.jar
>
> Failed to load Main-Class manifest attribute from
>
> test.jar
>
>
>
> D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>
>
>


You have to define your main class within the meta description of 
your jar file.

see

http://ant.apache.org/manual/CoreTasks/jar.html

BTW: It must be *.classes instead of *.classess in your build.xml

Regards

  Henning



Re: unable to execute JAR file

Posted by Ognjen Blagojevic <og...@etf.bg.ac.yu>.
> I have 10 java files and I have written Ant build.xml to compile and 
> create JAR file which contains the .class files. Now my requirement is 
> that I need to execute/install the JAR file but unfortunately I can’t do 
> this as I am getting following error.
...
> Failed to load Main-Class manifest attribute from

You should read a bit about manifest files. See this link[1].

In short, JVM doesn't know which class has the main method to be used as 
the entry point to your application.

-Ognjen

[1] 
http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: unable to execute JAR file

Posted by "Knuplesch, Juergen" <Ju...@icongmbh.de>.
Use classname attribut instead of MANIFEST:
 
<java classname="yourcountry.company.yourclass" maxmemory="512m" fork="yes" dir="${yourdir}" timeout="10000000">

 

--
Jürgen Knuplesch        


________________________________

Von: Irfan.Sayed@t-systems.com [mailto:Irfan.Sayed@t-systems.com] 
Gesendet: Mittwoch, 18. Juni 2008 09:26
An: user@ant.apache.org
Betreff: unable to execute JAR file



Hi All,

 

I have 10 java files and I have written Ant build.xml to compile and create JAR file which contains the .class files. Now my requirement is that I need to execute/install the JAR file but unfortunately I can't do this as I am getting following error.

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar test.jar

Failed to load Main-Class manifest attribute from

test.jar

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>

 

Please find the attached java code and build script.

 

Please help

 

Regards

Irfan.

 


RE: unable to execute JAR file

Posted by "Toomey, Kevin H (ATS, IT)" <Ke...@thehartford.com>.
Hi Irfan,
 
You need a manifest file with a main class attribute.
 
A quick googling of 'jar main-class' brings back a wealth of links to
check out. Here's one:
http://java.sun.com/developer/Books/javaprogramming/JAR/basics/run.html
 
Thanks,
Kevin

________________________________

From: Irfan.Sayed@t-systems.com [mailto:Irfan.Sayed@t-systems.com] 
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@ant.apache.org
Subject: unable to execute JAR file



Hi All,

 

I have 10 java files and I have written Ant build.xml to compile and
create JAR file which contains the .class files. Now my requirement is
that I need to execute/install the JAR file but unfortunately I can't do
this as I am getting following error.

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>java -jar
test.jar

Failed to load Main-Class manifest attribute from

test.jar

 

D:\Irfan\Manvendra Singh java code\Manvendra Singh java code>

 

Please find the attached java code and build script.

 

Please help

 

Regards

Irfan.

 



*************************************************************************
This communication, including attachments, is
for the exclusive use of addressee and may contain proprietary,
confidential and/or privileged information.  If you are not the intended
recipient, any use, copying, disclosure, dissemination or distribution is
strictly prohibited.  If you are not the intended recipient, please notify
the sender immediately by return e-mail, delete this communication and
destroy all copies.
*************************************************************************