unable to execute JAR file

View: New views
9 Messages — Rating Filter:   Alert me  

unable to execute JAR file

by Irfan.Sayed :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

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.

 


<project name="Test" default="compile" basedir=".">
<property file="build.properties"/>

<property name="compile.debug"       value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize"    value="true"/>
<property name="manager.url"   value="http://localhost:8080/manager"/>
<property name="app.path"      value="/${app.name}"/>

<path id="compile.classpath"/>

<target name="compile">
<!-- Compile Java classes as necessary -->
    <mkdir    dir="classess"/>
    <javac srcdir="."
          destdir="classess"
            debug="${compile.debug}"
      deprecation="${compile.deprecation}"
         optimize="${compile.optimize}">
    <classpath refid="compile.classpath"/>
    </javac>
        <!-- Create application JAR file -->
    <!--<jar jarfile="${dist.home}/${app.name}-${app.version}.war"-->
        <jar jarfile="test.jar"
         basedir="./classess"/>
        </target>
</project>


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

javacode.zip (19K) Download Attachment

Re: unable to execute JAR file

by Henning Bredel-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wednesday 18 June 2008 09:25:42 Irfan.Sayed@... 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




signature.asc (196 bytes) Download Attachment

Re: unable to execute JAR file

by Ognjen Blagojevic-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Irfan.Sayed@... 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@...
For additional commands, e-mail: user-help@...


Re: unable to execute JAR file

by Ognjen Blagojevic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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@...
For additional commands, e-mail: user-help@...


Re: unable to execute JAR file

by Prashant Reddy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... 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@...
> For additional commands, e-mail: user-help@...


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


AW: unable to execute JAR file

by Knuplesch, Juergen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... [mailto:Irfan.Sayed@...]
Gesendet: Mittwoch, 18. Juni 2008 09:26
An: user@...
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

by Taj, Abdul :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... [mailto:Irfan.Sayed@...]
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@...
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

by Irfan.Sayed :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...]
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@... [mailto:Irfan.Sayed@...]
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@...
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.
--------------------------------------------------------


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

RE: unable to execute JAR file

by Toomey, Kevin H (ATS, IT) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... [mailto:Irfan.Sayed@...]
Sent: Wednesday, June 18, 2008 3:26 AM
To: user@...
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.
*************************************************************************

LightInTheBox - Buy quality products at wholesale price