views:

223

answers:

5

First of all, I'm not a Java developer. I don't know much about it. Your help is needed, Java pros! I've received source code for a Java product (actually a customized version of LimeWire) to make further changes. The archive contains a bunch of JAR files. Is it sufficient for developing the application, or those files for distribution only?

Thanks!

+8  A: 

A jar is analogous to a zip file, so they may or may not contain the source code you need for development. You can read about jar files here.

Justin Pinkley
WinZip or any other archive manager can open .jar files. You may need to change the extension to .zip for some archivers.
Chris Nava
*"A jar is analogous to a zip file"* - a JAR file **is** a ZIP file that follows certain conventions about the archive contents.
Stephen C
+3  A: 

Normally you package up .class (compiled) files and distribute them in .jar files, but it is possible to put any kind of file you want (including source code) in a .jar archive. If you need to change the code in the library, you'll need to see the source.

It's also possible that the .jar files in your project are 3rd-party (or internal proprietary) libraries that you won't need to change at all. It's quite common to include libraries that you just use without modifying in your jar. If the rest of your application code is accessible, you can just modify that w/o touching the library code.

Bill the Lizard
If jars contain .class files only, does that mean I can't modify the application?
Sphynx
You can still modify .class files. It's just a whole world of hurt harder.
JUST MY correct OPINION
@Sphynx: Yes, as noted, it is possible, but prohibitively difficult. I'd go to great lengths to lay hands on the source code before trying to work with the .class files alone.
Bill the Lizard
+1  A: 

Any modern Java IDE allows you to drop in jar files and use that as library code. This does not require source etc. You can then develop new code, that incorporates changes.

If you need to ALTER code inside the jars, you would be much, much better of by having the source code for that jar you need to update, and then work with that.

If you do not have source code, and you need to change a class, then you can decompile that class using e.g. JAD to a Java file (be careful, may contain bugs), and then work with that. You just need to have that class in front of the jar in the classpath (unless the jar is sealed, and then you have a whole new question for stackoverflow).

Do you have more experienced Java programmers on your team, you can ask for assistance?

Thorbjørn Ravn Andersen
A: 

you can try decompiling the jar files back into their source, otherwise the jar files won't help much for development.

jar files can however help you when they contain some libraries/packages/classes that you find essential for a project you are working on. That way you can add them to your compilation path if you are using Netbeans IDE and use them without even peeking at the source. However this will work best if you are doing some kind of incremental development on your project. so, it highly depends on how you are building your software i.e. is it incremental or might you want to modify what you received... for the latter you ,might consider de-compilation or asking for the source code

jgt
+1  A: 

I've received source code for a Java product ...

If you have really received the source code of a product, and all you've got is JAR files, then the JAR files (which are actually ZIP files with a different file suffix) should contain a bunch of files with the file suffix ".java". You should be able to check this using any ZIP archive tool.

If there are no ".java" files in the JARs (e.g. only a lot of ".class" and other files), you do not have the source code for the product. Making changes will be really really hard, given that you are not a Java developer.

Assuming that you are doing this legitimately (i.e. with the explicit or implicit permission of the product's developer) you will save yourself a lot of time if you can also get hold of the product's build instructions. For example, if it is built using Ant, you want the "build.xml" file(s).

Stephen C