How to view the source code of wizardDialog in Eclipse? - plugins

I press Ctrl+Shift+T in Eclipse and try to view the source code of WizardDialog class, but error happens: Source not found, the JAR of this class file belongs to container 'External Plug-ins' which does not allow modifications to source attachments on its entries...
Where can I get the source code? Any URL to download it?
Thank you!

Generally has two solutions:
create a folder named sources under the same directory with the jar file, and put the source code into that folder. Then restart the eclipse.
Add the jar file into the classpath, then the attachment of the source code will be allowed.

Related

Eclipse src folder empty

So for my class I need to use eclipse to do some graphics stuff in Java. I've tried both Eclipse standard 4.4 and Eclipse for Java developers, but with both when I tried to create a new Java project, the src folder is completely empty. Why is that?
Edit: I should add in more information. In the lab section of my class I was able to follow the instructions and create a lab 1 project src folder, which contains many files such as Lab1.java, Polygon1.java and all that. When I am trying to do it on my own machine, it's not working
Because it's a blank canvas!!
Right click on the src file New->Class
Give the new class a name and a package and you're away, you can start coding.
If you want to include libraries create a new lib folder at the same level as the src folder and copy any jar folders into this folder. Right click on the .jar files and click Bukd Path->Add to Build path, you'll now be able to import and classes contained in this jar file(s)!!!
Because you created a new project. If you haven't added any code yet, why would there be code in the src folder?

How to display the source code of an external JAR in Eclipse?

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

Eclipse: include source code while exporting as runnable jar

I understand how to include other needed libraries or outside resources while creating a runnable .jar file in eclipse, but what I don't see is an option to also include the src .java files as well.
How could I accomplish this?
In the Export --> Jar File dialog you have the option to incluse source files and resources.
To make runnable a standard Jar File you only need to add/include an appropiate MANIFEST.MF on your own ...
Export to Runnable jar.
Open the Runnable Jar with WinRAR.
Click Add button, select the src.zip file.
I know this is answer is very late, but for those who still read this:
Eclipse has this option. You probably just did not notice it. I haven't checked since what version, Eclipse Luna has it for sure.
Export --> Jar File
then do not click Finish, but click Next.
You have more options there.
You will probably have to click Next twice to get to the Main Class selection.

How to place a file on classpath in Eclipse?

As this documentation says, "For example if you place this jndi.properties file on your classpath", but how can I place the .properties file on my classpath if I am using Eclipse?
Just to add. If you right-click on an eclipse project and select Properties, select the Java Build Path link on the left. Then select the Source Tab. You'll see a list of all the java source folders. You can even add your own. By default the {project}/src folder is the classpath folder.
One option is to place your properties file in the src/ directory of your project. This will copy it to the "classes" (along with your .class files) at build time. I often do this for web projects.
This might not be the most useful answer, more of an addendum, but the above answer (from greenkode) confused me for all of 10 seconds.
"Add Folder" only lets you see folders that are the sub-folders of the project whose build path you are looking at.
The "Link Source" button in the above image would be called "Add External Folder" in an ideal world.
I had to make a properties file that is to be shared between multiple projects, and by keeping the properties file in an external folder, I am able to have only one, instead of having a copy in each project.
Well one of the option is to goto your workspace, your project folder, then bin copy and paste the log4j properites file.
it would be better to paste the file also in source folder.
Now you may want to know from where to get this file, download smslib, then extract it, then smslib->misc->log4j sample configuration -> log4j here you go.
This what helped,me so just wanted to know.
Copy the file into your src folder. Go to the Project Explorer in Eclipse, Right-click on your project, and click on "Refresh". The file should appear on the Project Explorer pane as well.

Eclipse : How to remove the attached Source which was added to a Jar

I am using Eclipse IDE (Helios Version).
As part of the build path, I have a jar file for this Application, I have attached the source code for this jar file using Attach Source Option.
Please tell me how can I remove this attached source for the jar file?
Open the .classpath file and delete the source attachment part.
Or in the Build Path control panel, find the jar file and remove the source attachment (it is one of the detailed options there).
If you have two different projects in eclipse that are linked, the best way is to open both of them in eclipse workspace. If you do that, you don't need to "Attach Source..."
If you added the second project as a Source Attachment by mistake, you could try to remove the projects from eclipse workspace and adding them again. That worked for me.