Invalid or corrupt jarfile.

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 16672 Views - Last Post: 20 July 2010 - 01:05 AM Rate Topic: -----

#1 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Invalid or corrupt jarfile.

Posted 17 July 2010 - 03:48 PM

Hi guys! I'm relatively new to java and am trying to make a jarfile of a game I made.

I'm using JCreator and i'm using this tutorial http://www.skylit.co.../createjar.html, but still getting an error of "Invalid or corrupt jarfile".

I created the Manifest file in the same folder and left a blank line below it just like it said and changed the arguments in JCreator and created the jar file.

Some things that might create error is in the arguments line
cvfm $[PrjName].jar manifest.txt *.class
it says "PrjName". My file isn't a project it's just a regular java file so I'm not sure if it makes a difference or not.

Oh, and when it creates the jar file I go to the folder where it created it (the same folder where the class file is) and it just says ".jar", there's no front file name if that makes sense.

Any help is appreciated :)

Is This A Good Question/Topic? 0
  • +

Replies To: Invalid or corrupt jarfile.

#2 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3093
  • View blog
  • Posts: 19,139
  • Joined: 14-September 07

Re: Invalid or corrupt jarfile.

Posted 17 July 2010 - 03:57 PM

Does doing it "by hand" result in a similar issue?
Was This Post Helpful? 0
  • +
  • -

#3 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Re: Invalid or corrupt jarfile.

Posted 17 July 2010 - 05:20 PM

I ran command prompt and navigated to the directory and ran
jar cvf RunDown.jar RunDown.class
and it created the jar file but I get the error "Failed to load Main-Class manifest attribute from D:\.." when I try to run that jar file.

I'm assuming that's what you meant when you said doing it "by hand".
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Invalid or corrupt jarfile.

Posted 17 July 2010 - 08:49 PM

Yes but your "by hand" method does not include the manifest file

http://download.orac...asicsindex.html
Was This Post Helpful? 0
  • +
  • -

#5 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Re: Invalid or corrupt jarfile.

Posted 17 July 2010 - 09:54 PM

Thank you for the link!

So I should be doing "jar cmf Manifest.txt RunDown.jar RunDown.class", according to that website because I have an existing manifest already.

When I run the code above in the quotes I get the error "Could not find the main class: RunDown.class".

I slightly recall reading somewhere that manifest files need to be .MF extension but I may just be remembering incorrectly.
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,214
  • Joined: 20-September 08

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 01:43 AM

Quote

I slightly recall reading somewhere that manifest files need to be .MF extension but I may just be remembering incorrectly.


You are. It doesn't care what the extension is, but you must get the filename exactly right, and it's case-sensitive
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 11:29 AM

Do you use package statement(s) ?
If it is the case did you jar a level higher in the directory structure so that the full directory structure goes into the .jar
Was This Post Helpful? 0
  • +
  • -

#8 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 01:21 PM

I'm not sure exactly what that is, but I googled it and I don't think I need to use it. The folder that everything is in is the last folder in the directory.

It contains the .class file, the Manifest file and the Java file, and that is all the items for the game.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 06:10 PM

View PostCoca, on 18 July 2010 - 02:21 PM, said:

I'm not sure exactly what that is, but I googled it and I don't think I need to use it. The folder that everything is in is the last folder in the directory.

It contains the .class file, the Manifest file and the Java file, and that is all the items for the game.

No the .mf file but obviously you are not using it
so your .mf will be in the same directory as your .class
So g00se question remains our last resource... do you spelled all your class correctly ?
Was This Post Helpful? 0
  • +
  • -

#10 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 06:33 PM

Yes, I checked everything 10 times. The java file, class file, class in the java file, manifest file.. It all seems to be spelled correctly.
Was This Post Helpful? 0
  • +
  • -

#11 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 06:39 PM

View PostCoca, on 18 July 2010 - 07:33 PM, said:

Yes, I checked everything 10 times. The java file, class file, class in the java file, manifest file.. It all seems to be spelled correctly.

Really sorry about that so:
- post the output on a dir/ls command on your directory
- post the code of your .mf (or .txt in your case)
- post your Java code showing the beginning of your file and the beginning of tour main() method

can't beleive we won't find what is wrong
Was This Post Helpful? 0
  • +
  • -

#12 Dogstopper  Icon User is online

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,023
  • Joined: 15-July 08

Re: Invalid or corrupt jarfile.

Posted 18 July 2010 - 09:57 PM

View Postpbl, on 18 July 2010 - 08:10 PM, said:

so your .mf will be in the same directory as your .class


Isn't the manifest supposed to be in the META-INF folder?

Attached Image
Was This Post Helpful? 0
  • +
  • -

#13 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,214
  • Joined: 20-September 08

Re: Invalid or corrupt jarfile.

Posted 19 July 2010 - 04:08 AM

Quote

Isn't the manifest supposed to be in the META-INF folder?


That again is unimportant.

As pbl said, simply inserting the class files without regard for package structure will leave you with java unable to find the main class. The only way you can get away with that is if the main class (and any other classes you add) are in the default package ('no package')
Was This Post Helpful? 1
  • +
  • -

#14 Coca  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 36
  • Joined: 17-July 10

Re: Invalid or corrupt jarfile.

Posted 19 July 2010 - 11:32 AM

Ok here's my Manifest file(starts a new line too):
Main-Class: RunDown.class


And here's the beginning of my java file:
import java.util.*;
import java.io.*; 
import java.awt.*;
import java.awt.event.*;
import java.awt.Image.*; 
import javax.swing.*;
import javax.swing.Timer.*;
public class RunDown {
	public static void main(String args[])throws IOException { 

I'm not completely sure what you mean by "post the output on a dir/ls command on your directory". Could you explain what you mean by that. Sorry :(

This post has been edited by Coca: 19 July 2010 - 11:35 AM

Was This Post Helpful? 0
  • +
  • -

#15 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2657
  • View blog
  • Posts: 11,214
  • Joined: 20-September 08

Re: Invalid or corrupt jarfile.

Posted 19 July 2010 - 11:50 AM

Make that

Main-Class: RunDown


If it still doesn't work, can you post the full source code?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2