I have a WAR file with Java codebase. I need to decompile my war to a project in Eclipse
To do that I install Eclipse Jee 2018-12 and I had clicked in File->import and I selected warFile, and I put my file war
but I have this when I go to src to see code java I have just package
When I click in open type hiererchy i have this
How I can get source file content?
i always prefer to do it outside eclipse. its pretty easy if you just want to view the code.
you can use tools like jdecompiler . just select/open you war file.
Related
In Eclipse, I just imported an external JAR. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only JAR, no lib, no src, no docs.
Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
.jar files don't contain source code but are more like binary files for Java.
You can either get the source code from the projects page (if it is an OpenSource project of course)
An other possible way to view the source code of a .jar file is by using a decompiler (http://jd.benow.ca/; Also has a Eclipse plugin I think). This method can be very painful though when an obfuscator has been used by the developer who generated the .jar file.
Try this :
Download java decompiler from http://jd.benow.ca/ and now double
click on jd-gui and click on open file.
Then open .jar file from that folder.
Now you get class files and save all these class files (click on file
then click "save all sources" in jd-gui) by src name.
You cannot view the source form a .jar files as it contains binaries.Use a java decompiler instead to decompile the .class files and view their sources.
If possible I suggest you to use Maven for manage dependencies of your project, in most cases it did the trick for you.
See: Get source JARs from Maven repository
How can I install the JGraphT distribution offered in this link:
http://sourceforge.net/projects/jgrapht/files/
I do not understand the tree structure of files and its relation with the structure of a project in Eclipse. I would like to run the java code listed in:
http://jgrapht.org/visualizations.html
but I am not able to import the proyect to Eclipse. For example, that .java file is under
jgrapht-0.9.0\source\jgrapht-demo\src\main\java\org\jgrapht\demo
Follow these steps:
1) download the .zip file on that page
2) create a new java project in eclipse
3) unzip .zip file
4) right click on the 'src' folder and select 'import...' from file system
5) select 'src->org' under the unzip files
6) you will need 'jgraph' to run any of the examples
You can import the jars as internal/external jars into your project.
For example, right click on the project -> Build Path -> Configure Build Path
Then go to libraries and 'Add Jars' or 'Add External Jars' (if your jars are located outside the project space), you should now be able to import classes associated with JGraphT.
This works for me: Install JGraphT in Eclipse. I just downloaded jgrapht-1.0.1.zip and I use Eclipse Oxygen (4.7.1). The link above describes the steps in detail. Basically, do the following:
Download jgrapht-x.y.z.zip and extract it.
In Eclipse, create a new Java project.
Add the jars of the extracted jgrapht libraries to your Eclipse user libraries.
Add the just-added user libraries to your project's Build Path as libraries.
Now your project can make use of jgrapht.
I manually copy needed jar files into my project lib folder. Then, I try to add them to build path via "configure build path option". If i choose "add jar", then the lib folder does not show up in the "to choose from" list. So, I am forced to use "add external jars" option instead. But, that option does not make the jars a part of the project even though they lie in the lib folder. After I restart eclipse 2-3 times, the jars are magically integrated into my project.
Why is eclipse behaving this way ? Why can't I do this easily ?
Please help me.
By default, Eclipse dose not detect file change which come from outside, like copy a jar file in lib folder manually.
So after you copied jar files, you have to refresh the project by pressing F5 while selecting your lib folder. I believe that's why eclipse cannot found your jar files.
If you want to solve this problem once for all, you can active "Refresh using native hooks or polling" via
Window -> Preference -> General -> Workspace
However, this might slow down Eclipse if you have a big project with many many files.
UPDATE
As Bananeweizen mentioned, instead of doing all the copied from outside of Eclipse, you can also copied those file into Eclipse, Package Explorer View for example. This way Eclipse will detect and refresh folder automatically.
The way I was taught to add external jars to an eclipse project is to drag the jar file from explorer into the lib folder in eclipse and then on the dialogue eclipse responds with is choose the copy to option and eclipse imports the jar file and copies it to the lib location at the same time.
I have a netbeans project: java Web Application.
Some libraries in the project are'nt included in code directory. e.g.
....netbeans\7.1\var\cache\index\s717\java\14\gensrc\javax\mail\MimeMessage
so when I clone the project in other machine the library isnt found, because the netbeans directory is different. Is there a tool that check it? Maybe a netbeans plugin. thanks!
Try right-clicking on the Libraries in your Netbeans Project Browser, and selecting "Add JAR/Folder". From there, navigate to the JAR you want, and select "Reference as Relative Path".
I have a jar file that contains source code. How can I browse this source code in Eclipse?
At the moment, my Eclipse opens the jar file in a Text Editor, and it isn't that helpful.
When I look in the preferences "General" > "Editors" > "File Associations" I have no associations for *.jar and if I look in the available "Editors" I can't find anyone that seem to be a good fit for jar files.
How can I browse the source code in a jar file using Eclipse? Is there any Editor I should configure for jar files?
If you have the jar added to a project's classpath, you can view its source by:
Expanding Referenced Libraries in the Package Explorer view
Expand the jar you're looking at
Double clicking on a .class file
You need both the .class and .java file in the jar to view source, though.
If you have only the .java file, the class won't appear at all.
If you have only the .class file, the class will appear as bytecode.
Example:
Extract the jar in some source directory (it's a zip file), and create a project with this directory as source.
Or, if this source jar file contains the sources of a classes jar file that is used as a library in your Eclipse project, just right-click on this jar file, select "Properties", then "Java Source Attachment", then "External File", and select the source jar file. Then each time you browse a class from this classes jar file, Eclipse will automatically show you its source code.
If you want just to open jar o war files (and search or browse scripting code), install the Eclipse plugin called "Eclipse zip editor", from eclipse marketplace. Just in case it's the website to drag and drop to eclipse