How to get JavaDoc for Eclipse plug-in development? - java

I just started with developing plug-ins for Eclipse but whenever I create one of the sample projects there is no JavaDoc for the methods that are used in the generated code.
I'm using the HelloWorld example and in there there's for example this generated code:
public void run(IAction action) {
MessageDialog.openInformation(
window.getShell(),
"Miau",
"Hello, Eclipse world");
}
However the openInformation() method does not have any JavaDoc attached neither does MeesageDialog or any other class/method/interface used in the generated example.
Is there a way to add JavaDoc to those methods/classes/etc?

Whether JavaDoc is available depends how you set up your target platform. Source bundles or source features are necessary in order for the IDE to provide JavaDoc.
Moreover, sources allow to debug step through the platform code, look into the source if the documentaion isn't clear enough, etc. Hence, you will probably always want to have the sources.
If you add components to your target platform from a software site, make sure that the Include source if available option is checked.
When selecting components, prefer SDK features or also include Resource features. For example, include the Eclipse Platform SDK instead of the Eclipse Platform as it also contains source code and documentation. If your target requires the Eclipse Java Development Tools, make sure to also include the Eclipse JDT Plug-in Developer Resources, again the latter contains documentation and source code.

I thought the location was configured to the java site by default for working when online. If you want to have the documentation offline, do this:
First download and extract the javadocs for the JRE version you have installed.
From Eclipse go Windows -> Preferences -> Expand Java -> Installed JREs -> Select the JRE you want docs for -> Click Edit -> Select all of the System Libraries -> Click JavaDoc location and select the location where you extracted the docs.
*EDIT - Just noticed the method you are looking at isn't in core java. If you want to add Java Docs or Source to a referenced library, expand the references then right-click on the jar you want and select preferences, from there you can add the docs or source, which you should be able to download.

Related

How to configure IntelliJ for Mac to show Java and Android documentation within the editor (offline, not online)?

How do I configure IntelliJ to access offline documentation (for both Java and Android if possible) without leaving my IDE? I'm using IntelliJ IDEA 13.1. My Android application is building and running fine so my installation seems to be correct. I've examined the relevant SO posts:
How to view JDK external documentation in IntelliJ IDEA?
JDK documentation in IntelliJ IDEA on Mac OS X)
IntelliJ and the android java docs
But either the paths they recommend are not on my machine (the posts are rather dated) or else too vague. Interestingly my /Library/Java/JavaVirtualMachines folder seems to be empty whether I use Finder or Terminal. My Documentation paths tab under the File | Project Structure menu item is empty.
I should add that I'm attempting to use the Shift+F1 keyboard command when I have a keyword highlighted. That's what is recommended, but nothing happens. Below are pics of my current documentation paths in the Project Structure dialog. All done according to recommendations as far as I can see, but maybe someone can spot something.
I think configuring the path to src.zip should be enough, IntelliJ will retrieve the Javadoc from the source files. In Modules Settings, in the SDKs panel choose your current SDK, go to the Sourcepath tab and make sure there's an entry for src.zip.
On OSX it's located under
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/src.zip
or
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/src.zip
depending on which SDK you have and how you installed it.
For the Android doc, I guess you can do the same if they provide a zip containing all the source files.
Command + ; open Project Structure
on left panel select SDKs
in Sourcepath tab click +, select your src.zip

View sources of used Java classes in IntelliJ Idea

In visual studio development environment when you use a library if you have the related pdb you can dig into their sources during debug. I wonder is there any way to have this feature when you are developing under Java with IntelliJ Idea IDE?
I want to see what hibernate do.
Of course, quoting the documentation:
Libraries may optionally include the source code for the library classes as well as corresponding API documentation. [...] However, it adds the ability to use inline documentation extracted from the source code, and also to view the API documentation right from the IDE.
The documentation doesn't mention you can then debug external libraries, which is obviously also possible.
In order to add sources choose:
File | Project Structure
Click Libraries tab
Pick library and click + icon
Find a JAR file containing sources.
If you are using build tool like maven, IntelliJ will automatically download and attach available source to all libraries, no manual work needed.
In my case, I had to add the JDK source files to the project as below.
Go to Project Structure -> SDKs -> Sourcepath
Use the Plus Sign on the right, and provide the path to your $JAVA_HOME/src.zip file.
Go to ➙ Implementation(s)
No one suggested the simple route with a context-menu:
import java.util.DesiredClass
select this import statement
right click -> Go to -> Implementation(s)
Done! The source code of the DesiredClass opens in a new tab.
This also works with selected class name in the body of your code.
Project Structure | Libraries (or Module Dependencies if libraries are defined there):
Then in the libries tab click on the plus mark:
Select the source type:
Then you have to select the source path and add the wanted libraries finally click apply!
If you use maven, there is a button "Download sourcec" on maven panel.
If you don't, you need to get sources of hibernate first, search on the internet. And then attach them: File -> Project Structure -> Libraries -> Your hibernate lib -> and attach source
Sources for JAVA API
In Debian, and Ubuntu,
To be able to view sources for Java core API classes, you can install:
sudo apt install openjdk-11-jdk openjdk-11-source
openjdk-*-source package contains the Java programming language source files
(src.zip) for all classes that make up the Java core API.
Once installed, you should be able to find the installed content under:
/usr/lib/jvm/java-11-openjdk-amd64
/usr/lib/jvm/java-11-openjdk-amd64/src.zip
Then in IntelliJ, add the JDK, in project settings. If src.zip is present within the provided JDK directory, IntelliJ will automatically use it as the sourcepath.
Sources for external libraries
If you're using Maven, you can get source files for external dependencies by clicking on the button 'Download Sources and/or Documentation' provided in Maven tool window.

Changing Java Version From Within Eclipse

I wrote a project in eclipse with an older version of java.
Now on a different computer but running the same codes I'm getting a whole lot of red.
This is due to Version incompatibility.
I've had my professor change the Java version from within the console window before. The code compiled just fine after he did so. I'm sure its the same case with this code.
After looking at other tutorials and google links I could only find command line approaches and #override methods. To be honest I still don't understand these.
What is the best way to change the version of a code originally written in an older code inside the eclipse console?
thanks!
In eclipse go to Window -> Preferences -> Java -> Compiler, there you can change the java versions. Hope it helps.
Ideally if we want to have two different versions of Java [say 1.6 and 1.7], then we should have two workspace defined accordingly to avoid any mixup. We can also change the Project Facets if our projects has facets that is.
In Eclipse Follow steps given below:
1) Windows -> Preferences -> Java -> Compiler and as per the image set the compliance compiler level as per your requirements.
2) Windows -> Preferences -> Java -> Installed JRE's and check if your required jre/jdk is available or not as given in image below:
3) Right Click on Your Project and go to Java Build Path and check if your required Library is available or not as per image given below:
4) Now you can edit the JRE System Library or add one by clicking on button's available on last image's right side, then a pop up as given below will open up. Here, you can change the execution environment [default values also can be set]
In myeclipse select the project -> properties -> java compiler -> there you can specify jdk version.
Easy
Download the jdk from Oracle's official website for the version you want to compile your project with.
JDK Oracle's official
create a new Java project
[
Once the project has been generated, If you select the part that says Configure JREs
By default eclipse will use the version you have installed on your system so if you don't change this configuration you will never be able to run the program with the build you need, in this case I will use jdk 1.8.
After pressing Add
5.1 And choose the option select the 3rd option in this case, called Standard VM and press Next
Now eclipse asks us to indicate the path where the libraries and other content is located in order to compile and run the program, we only have to indicate the directory where it is located.
As my goal is to run a program with the JRE 8 , I will look for the directory path where the download described in option 1 of this message is located.
As a quick example, since I just want my program to compile without worrying about anything else, I will add all the contents of my address.
Now we change by clicking on the JRE we want to compile our program, to be changed to the original default so that the new selection is executed ; and finally we press Apply and Close and Next
Press Finish to create the project
Now we have the whole project with all the necessary content to compile and run it.
Personally I think this is the quickest and cleanest way to do it ; the problem I encountered when I changed JDK is that when compiling I couldn't find the directory with the necessary components to run it, you had to download it and configure it together with the default parameters, which can cause a lot of headaches for less experienced users.
Finally, this is the version of eclipse that I am using
I hope you find this system useful, I use it to be able to run old examples that use applets , which are obsolete classes and jvm does not compile.

Eclipse Helios not showing Javadoc

I have recently got a new computer and I have put Eclipse Helios on there. Before, on my old computer, when I used the control-assist (Ctrl + Space) and highlighted the suggested methods, the Javadoc for that method used to appear at the side of the control assist pop up window with the method description and parameters etc...
However, on my new computer this Javadoc doesn't appear and only the method suggestions appear - but even the arguments for the methods aren't named (they're just called arg0, arg1 and so on). The only thing I can think of that is different on the new install is ZoneAlarm but as far as I can see I have allowed eclipse through the firewall; unless it's something to do with Java itself.
This feature is really useful to me so any advice on how to resolve this issue would be greatly appreciated. Thanks in advance.
Eclipse is using a JRE instead of a JDK as the default Java.
Download and install a JDK.
In Eclipse Preferences, Java -> Installed JRE's. Use "Add" or "Search" to locate and add the JDK just installed.
Move the check mark indicating the default Java to the newly found JDK.
Allow the workspace to rebuild.
You need to press F3 on the Class or Method name you want to see javadoc for. Then in the editor it's source will open or if you don't have source attached, you'll have screen with bytecode saying that no sources attached. Then you need to open package view, by default it's on the left side. On the top of it there is an icon with two arrows, if it's not pressed, press it. It will show source you've opened in the package view, then you need to find jar file containing your source by scrolling up if you already don't stand on it.
Now press right mouse button on that jar, you'll see properties window. Select javadoc, then you need to select location of the javadoc. You can provide a URL to an online javadoc. The URL you will be pointing to must provide a page named 'index.html' or similar or Eclipse won't allow you to use that URL. Also you can download javadoc locally and then select the location of that javadoc archive. If you need the javadoc for java SE libraries, you can find it in your jdk installation directory in src.zip folder. Hope it'll help.
Did you specify the javadoc location of your library?
Window -> Preferences -> Java -> Installed JREs -> Select your JRE -> Edit -> Select .jar file(s) (rt.jar) -> Javadoc Location

How to add online available javadoc to a downloaded Library in Netbeans?

maybe the answer is easy, but I'm unable to find information about the topic on google.
I've downloaded the MacWidgets Library from http://code.google.com/p/macwidgets/.
On the site you can also find the javadocs and I would like to integrate this into Netbeans to provide me with information about classes / methods while typing like on the normal java api.
Is this somehow possible? Or do I have to download the source, create a project out of it and reference the project instead of the libraries?
I confirmed with the latest NetBeans IDE 7.0 M2 version released on http://www.netbeans.org
They have provided support for URL configuration for the Javadoc.
Steps to use this feature
First create a library for the MacWidgets JAR files using Tools > Libraries dialog box.
For the created library set the URL of the Javadoc using the Javadoc tab and URL button, in this case the URL shall be http://exploding-pixels.com/google_code/javadoc_0.9.5/
Now when any class from this library is referred in the Java code editor NetBeans will show Javadoc in below the context sensitive code completion as well as in the javadoc window if it is open.
This feature is recently added and only available from NetBeans IDE 7.0 M2, release and onwards. This feature is still having some issues and opening Javadoc directly by right clicking the JAR node in the project panel library node does not work yet.
UPDATE (29 Apr 2011)
With the release of latest NetBeans IDE 7.0 the issues related to Javadoc from URL are solved. You can use a HTTP URL to specify Javadoc for third party libraries without any issues now. The issue reported by me about right clicking the JAR node is also fixed by the NetBeans developer team.
Just as an addition, if you are using cut and paste from on-line javadocs, don't forget to remove the index.html as it messes up the url.
Step 1: Go to the /Libraries/.jar
Step 2: Right-click on the particular jar file.
Step 3: 4 options will appear --> select Edit
Step 4: Click on Edit.
Step 5: Browse Javadoc and provide the doc path till API.

Categories

Resources