Skip to main content
added 80 characters in body
Source Link
rsp
  • 23.4k
  • 6
  • 59
  • 72

I am trying to work through the HelloWorld example on the Web that shows you how to create a build file using ANT in Eclipse. This is the project build file from the web example

 
<?xml version="1.0" encoding="UTF-8"?> <project name="HW.makejar" default="makejar" basedir="."> <target name="makejar" description="Create a jar for the HW project"> <jar jarfile="HelloWorld.jar" includes="*.class" basedir="."/> </target> </project> 

But when I run the resulting jar, I get this error message failed to load Main-Class manifest attribute from HelloWorld.jar.

So then I tried it like this:

  
<?xml version="1.0" encoding="UTF-8"?> <project name="HW.makejar" default="makejar" basedir="."> <target name="makejar" description="Create a jar for the HW project"> <jar jarfile="HelloWorld.jar" includes="*.class" basedir="."> <manifest> <attribute name="Main-Class" value="ami.HelloWorld" /> </manifest> </jar> </target> </project> 
  

When I reran the resulting jar, I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: ami/HelloWorld

Exception in thread "main" java.lang.NoClassDefFoundError: ami/HelloWorld 

What am I doing wrong. By the way, when I manually compile the source and specify the Main.class within Eclipse, the resulting jar runs perfectly.

I am trying to work through the HelloWorld example on the Web that shows you how to create a build file using ANT in Eclipse. This is the project build file from the web example

 

But when I run the resulting jar, I get this error message failed to load Main-Class manifest attribute from HelloWorld.jar.

So then I tried it like this:

 
</target> 
 

When I reran the resulting jar, I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: ami/HelloWorld

What am I doing wrong. By the way, when I manually compile the source and specify the Main.class within Eclipse, the resulting jar runs perfectly.

I am trying to work through the HelloWorld example on the Web that shows you how to create a build file using ANT in Eclipse. This is the project build file from the web example

<?xml version="1.0" encoding="UTF-8"?> <project name="HW.makejar" default="makejar" basedir="."> <target name="makejar" description="Create a jar for the HW project"> <jar jarfile="HelloWorld.jar" includes="*.class" basedir="."/> </target> </project> 

But when I run the resulting jar, I get this error message failed to load Main-Class manifest attribute from HelloWorld.jar.

So then I tried it like this:

 
<?xml version="1.0" encoding="UTF-8"?> <project name="HW.makejar" default="makejar" basedir="."> <target name="makejar" description="Create a jar for the HW project"> <jar jarfile="HelloWorld.jar" includes="*.class" basedir="."> <manifest> <attribute name="Main-Class" value="ami.HelloWorld" /> </manifest> </jar> </target> </project> 
 

When I reran the resulting jar, I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: ami/HelloWorld 

What am I doing wrong. By the way, when I manually compile the source and specify the Main.class within Eclipse, the resulting jar runs perfectly.

Source Link
Elliott
  • 5.6k
  • 11
  • 52
  • 91

creating a build file with ant

I am trying to work through the HelloWorld example on the Web that shows you how to create a build file using ANT in Eclipse. This is the project build file from the web example

But when I run the resulting jar, I get this error message failed to load Main-Class manifest attribute from HelloWorld.jar.

So then I tried it like this:

</target> 

When I reran the resulting jar, I got the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: ami/HelloWorld

What am I doing wrong. By the way, when I manually compile the source and specify the Main.class within Eclipse, the resulting jar runs perfectly.