my dog learned polymorphism*
The moose likes IDEs, Version Control and other tools and the fly likes How to import a jar file into eclipse as a project to use source code of classes of that jar. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to import a jar file into eclipse as a project to use source code of classes of that jar." Watch "How to import a jar file into eclipse as a project to use source code of classes of that jar." New topic
Author

How to import a jar file into eclipse as a project to use source code of classes of that jar.

Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Hi,

I have one jar file. I want to see the source code of classes of this jar file and i need to use source code of this jar file. Is there any option to view and use that jar file source code?
Is there any option in eclipse to extract jar file and to see the source code of that jar file?

Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Is the source code available at all?
Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Ivan Jozsef Balazs wrote:Is the source code available at all?



I dont have source code, is there any possibility to see the source code of classes present in that jar file in eclipse?

Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
A jar files typically contains class files and other resources, typically no sources, albeit it is not unconceivable.

The class files do not contain every information the sources do. For example local variable and parameter names will be missing. Neither Eclipse nor other tool will be able to recover them if these pieces of information are missing. The method names and parameter types are of course visible.
Mani Raju
Ranch Hand

Joined: Oct 09, 2012
Posts: 46
Actually, i tried to add plug in eclipse but i am getting error by selecting "Help-->Install new software". The error is "Can not complete the request : The installation not configured properly for software updates. See the error log file for details."
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

What plugin did you try to install? The log file mentioned is at workspace/.metadata/.log, look in there for additional details.

Usually you don't need the source to access classes and their methods that are packaged into a JAR. All you really need to do is add the JAR to the build path of your project. Eclipse will then let you browse through the classes in the jar and view all public fields and methods.


JBoss In Action
 
GeeCON Prague 2014
 
subject: How to import a jar file into eclipse as a project to use source code of classes of that jar.