Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ezrafitch1990

macrumors newbie
Original poster
Jul 21, 2010
4
0
New here, hope I'm doing things right.

I've done a lot of searches and gotten some great info, but alas, I'm stuck and hours of searching has yielded no solution to my problem :(

Basically there is this jar file that I'm trying to add some .class to, I've extracted it fine, by using two different methods. First renaming it from a .jar to a .zip and extracting it which works fine. And after some searches, I also used Terminal's
Code:
jar -xvf <jarfile>
which also extracted the jar file fine. There were 4 folders extracted.

I added my .class files, and used:
Code:
jar cf File.jar *
which makes a nice File.jar file in the directory I'm working in. Double click to launch, and it says the file cannot be launched?

Fine, to see if the error is coming from the .class files I've added I decompiled (using both methods to see if it was an error in extracting) and did not change/add anything to the original .jar extraction. Tried to recompile without any changes, a .jar file was created, tried to run, but again I get an error saying it can't be launched.

Extracted my created .jar file, and it creates the exact same 4 folders as extracting the original jar file. Except my jar file does not run, but hte original launches fine.

Any help for a noobie? Thanks.
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
Look at the Console, as the error message says. That will clue you in as to what's going wrong.

If the error message in Console looks something like: java.lang.NoClassDefFoundError: can't find class: MainClassName
... then you've put the main class in the wrong place, or it doesn't exist, or the manifest file specifies the wrong class, or the manifest file is corrupted.

If you get a message like this:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
... then the version of Java being used to launch the .class inside the JAR file is older than the version of Java the .class was compiled with.

Anything else, please post here (and use CODE tags!)
 

ezrafitch1990

macrumors newbie
Original poster
Jul 21, 2010
4
0
Hi, thanks for the response wrldwzrd, hopefully this fix doesn't go too far beyond my knowledge, since I'm not a java developer, but I'll see what I can do.

I ran the .jar file I compiled (unmodified) and I do get the error message referring to the console. I open up the console and no new messages appear referring to the failed launch of the .jar file I tried to open. So i tried launch the .jar again to see if anything else appears in the console, but nothing although I am getting the error message again to refer to the console
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
Hi, thanks for the response wrldwzrd, hopefully this fix doesn't go too far beyond my knowledge, since I'm not a java developer, but I'll see what I can do.

I ran the .jar file I compiled (unmodified) and I do get the error message referring to the console. I open up the console and no new messages appear referring to the failed launch of the .jar file I tried to open. So i tried launch the .jar again to see if anything else appears in the console, but nothing although I am getting the error message again to refer to the console
You're probably looking in the wrong log file - go to All Messages in the Console. The error should appear there.
 

ezrafitch1990

macrumors newbie
Original poster
Jul 21, 2010
4
0
thanks so much wrldwzrd, looks like I'm getting the NoClassDefFoundError you mentioned earlier.

This is the original file I am trying to extract/recompile:
http://www.rsbot.org/go/download
clicking will automatically download the .jar file.

I moved the manifest file from the META-INF folder to the main directory with all the extracted folders and did this command:
Code:
jar cvfm File.jar MANIFEST.MF -C *
which looked promising, terminal scrolled through "adding" this "deflating" that, but in the end the .jar file created will not run. And console is giving me the NoClassDefFoundError
 

wrldwzrd89

macrumors G5
Jun 6, 2003
12,110
77
Solon, OH
thanks so much wrldwzrd, looks like I'm getting the NoClassDefFoundError you mentioned earlier.

This is the original file I am trying to extract/recompile:
http://www.rsbot.org/go/download
clicking will automatically download the .jar file.

I moved the manifest file from the META-INF folder to the main directory with all the extracted folders and did this command:
Code:
jar cvfm File.jar MANIFEST.MF -C *
which looked promising, terminal scrolled through "adding" this "deflating" that, but in the end the .jar file created will not run. And console is giving me the NoClassDefFoundError
Sounds like the MANIFEST.MF file isn't in the right spot in the JAR archive. It needs to be in the META-INF folder.
 

mrbash

macrumors 6502
Aug 10, 2008
251
1
Are you getting the NoClassDefException when you run the original JAR?

If you are not, then it is the way you are packaging the JAR file. Manually packaging a JAR file is a little bit clunky and I mostly prefer to use a tool such as ANT or something built into my IDE.

In your case I would recommend that you look at the file layout of the original JAR file and duplicate that in another directory. Then simply ZIP up the directory and rename the ziped archive with a .jar extension. A JAR file is essentially a ZIP file.

If you don't want to try the above solution, try posting the recursive list of your JAR file contents, and the contents of the Manifest.mf file in the archive. Also post the command you are using to execute the JAR.

We can then see what's going on.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.