Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Newbie: Source files location from jar

Reply
Thread Tools

Newbie: Source files location from jar

 
 
ankur.sanghi@gmail.com
Guest
Posts: n/a
 
      03-06-2007
Hi,

I am a complete newbie here (worked for all my life in Mainframes/
Unix). I want to locate the actual source files for one of the
applications I am currently working on.


All I know from the logs is the location of the jar files. Is it
possible to figure out where the source could be located by looking
at
the jar files? OR


Is there some other way to backtrack where the source files are?


Obviously, this is all arising from poor documentation about the
system...


Please help.


Regards,
Ankur

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      03-06-2007
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> I am a complete newbie here (worked for all my life in Mainframes/
> Unix). I want to locate the actual source files for one of the
> applications I am currently working on.
>
>
> All I know from the logs is the location of the jar files. Is it
> possible to figure out where the source could be located by looking
> at
> the jar files? OR


In general, no.

> Is there some other way to backtrack where the source files are?
>
>
> Obviously, this is all arising from poor documentation about the
> system...


You said you were "working on" the application whose source you
desire. By "working on", do you mean you are (one of) the programmer(s) of
that application? If so, then wouldn't whatever text editor you were using
to edit the source code have some sort of "history" function to show you
where you might have saved the source?

Otherwise, if you are not a programmer of the application, do you even
have any reason to believe you would have access to the source code in the
first place? I.e. did the programmers actually give you the source code at
some point, or might they have merely given you the application, keeping
the source code as their internal trade secrets or intellectual property?

- Oliver


 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      03-06-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Is there some other way to backtrack where the source files are?


If you are working without any information at all, then the best you can do
(and it is not guaranteed to be reliable) is to find the names of some of the
classes in the JAR file, and then look for corresponding source file names in
your source directories or code repository.

To extract classnames from a JAR file do:

jar -tf whatever.jar

or (the same, but with more information about each file in the JAR):

jar -tvf whatever.jar

Ignore everything which doesn't end with ".class". Also ignore anything which
has a '$' in the filename. Discard everything up to and including the final
'/' in each name, and replace the trailing 'class' with '.java'. That
/should/ give you the names of the source files -- then you have to go looking
for them.

Obviously there are potential problems with that. One is that the source may
no longer be available; another is that you may find more than one source file
with the same name. More unlikely, whatever build system was used to create
the JAR may have renamed or otherwise changed things so that this technique
doesn't work -- but that's the exception rather than the rule.

Good luck !

-- chris


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Location, location, location =?Utf-8?B?VHJhY2V5?= Wireless Networking 2 02-17-2007 08:37 PM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM



Advertisments