missing javadoc detail in intelliJ - java

Just switch the IDE from Eclipse to intelliJ, when I use ctrl+q to try to pop up more explainations for the method, it shows no details like this. How can I fix it to get same information as Eclipse does?

This is because you didn't set Java source path in the project structure dialog.
Go to File > Project Structure and select SDKs from the left side. Then select your project JDK level (In your case it should be 1.8) and add JDK source path in Sourcepath tab.
Usually it should be named as src.zip and placed inside your JDK folder.

Trying to follow #Chathura Buddhika's answer I found I didn't have the jdk source installed:
$ file /usr/lib/jvm/java-8-openjdk-amd64/src.zip
/usr/lib/jvm/java-8-openjdk-amd64/src.zip: broken symbolic link to ../openjdk-8/src.zip
I installed the source package, restarted intellij, and then documentation "just worked". The Sourcepath got automatically added to the Project structure.
Debian/Ubuntu with open jdk8:
sudo apt-get install openjdk-8-source
Ref: https://stackoverflow.com/a/64340730/8954109

You can simply navigate to the class PrintStream where you can find the complete documentation by -
Right click on the method
Go to
Implementation
Select the class where you want to see its implementation
In this case PrintStream
(Shortcuts could vary as defined by users)

Related

Issue while installing Realignment for JD-Eclipse

I'm trying to debug a .class file using JD-Eclipse plugin. But while debugging some of the decompiled lines are skipping even after placing the break points in desired lines. After googling i came to know about another plugin called "realignment.jd.ide.eclipse_1.0.2.jar".
I performed the install procedure as per the SourceForge page and tried dropping the jar file in eclipse /plugins directory and restarted the eclipse(Also tried the /dropins directory). As per the site If we go under this Preferences/General/Editors/File Associations and select "*.class" file type. There we should choose "Realignment for JD Class File Editor" for Associated editors. But there was nothing as expected. Please someone guide me in right direction to use this realignment feature.
Current Environment:
Eclipse IDE : Eclipse Kepler
JAVA : JDK 6
Thanks in Advance.
You don't need the Realignment plugin. Just install the JD-Ecplise plugin, go to menu Window > Preferences, navigate to Java > Decompiler and check 'Realign line numbers' (you can uncheck 'Show original line numbers' since they will match the decompiled class text)

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.

how to add javaDoc to my Java code in a NetBeans based project?

How can I add JavaDoc or other document to netbeans ?
I try with this way :
Tools >> Java Platform >> JavaDoc Tab >> JavaDoc.zip (in my desktop)
but in editor when I press Ctrl+Space in tooltiptext this message shown :
Javadoc not found. Either Javadoc documentation for this item does not exist or you have not added specified Javadoc in the Java Platform Manager or the Library Manager.
I tried restarting NetBeans but this was the result:
try this in NetBeans IDE
Choose Tools > Java Platform Manager from the main window.
Select the platform to which you want to add Javadoc in the left panel of the dialog box.
In the Javadoc tab, click Add ZIP/Folder and specify the location of the Javadoc files.
Click Close.
Hope this helps.
If you are using maven in your project then follow below steps to attach Java docs for your attached libraries.
Right click on "Dependencies" folder of your project.
Then choose "Download javadoc" option
It will download javadoc of your libraries and attached it.
Now when you will press ctl + space then you will see docs for that library.
and If you want to add javadoc for particular library then follow the options as suggested by Himanshu Soni.
You can't usually just add the javadoc zip as a separate library (at least this hasn't worked for me in the past.) In the libraries section you need to select the library you want to add the Javadoc for and then add the Javadoc jar for that specific library.
Restart Netbeans then that should work. Though of course if there really is no Javadoc for that method you still won't get any (I've fallen into that trap a couple of times before!)
You followed the very right procedure, I've been threw this right before I write this answer, and as for this is the first result that shows up when you Google the problem, I think that many people will find it handy and save their time, the solutions is:
UNZIP the JavaDoc.zip file that you are referring to ( which is supposed to be jdk-7u4-apidocs.zip for JavaSE 7 docs) and repeat the same procedure, which is Tools --> Java Platforms --> Javadoc ( tab ) then press " Add Zip/Folder, and point to the unzipped folder instead of the zipped one, restart NetBeans, and it will work smooth and direct.
You should download the docs file from the following link:
http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
After completing the described operation, you will have your javadocs available offline, and you don't need to be connected to the internet to know about APIs.
Best regards brother.
"Tools >> Java Platform >> JavaDoc Tab >> JavaDoc.zip"
The problem with above step can be solved easily by moving down following two path already added in content panel as shown below.
Step 1-
Goto: Tools >> Java Platform >> JavaDoc Tab
and Add ZIP/Folder you want to add.
Step 2-
Step 3-
That's all and if zip file doesn't works the extract first and then add it.
I had the same problem, and I solved it by removing all URLs and adding only the apidocs.zip downloaded from oracle. After that restart your NetBeans.
Before test whether it works be sure the method you are looking for actually exists within the apidocs. Open index.html and make a search for that particular package.class.method you need.
If it doesn't work, try to manually copy the apidoc.zip to the docs directory of netBeans:
C:\Program Files\NetBeans 7.1.2\java\docs and then retry.
this help me:
http://wiki.netbeans.org/FaqJavaDoc#Adding_the_JDK_Javadoc_to_the_NetBeans_IDE
try it, maybe help
Using a Maven project inside of Netbeans v8.02.
First, view your project via the Projects window;
Expand your project's Dependencies folder
Right-click the desired *.jar file
Click download javadoc
Done!
This worked for me, I manually copy the apidoc.zip to the docs directory of netBeans: C:\Program Files\NetBeans 7.1.2\java\docs and then restart my netbeans.

How to get Java API Javadocs to show up in Eclipse in Ubuntu

I'm here again with a docs question.
At my university, when using Eclipse, when placing the cursor
over a Java API method name (for example: .size() ), I get
very nice documentation about it.
Here at home I get
Note: This element neither has attached source nor attached Javadoc
and hence no information could be found.
Any quick and simple apt-get fix?
Thanks in advance!!!!
Go to your JRE settings (Window > Preferences > Java > Installed JREs), select your current, then Edit it and set the Source Attachment for rt.jar.
You might have to install the sun-java6-source or openjdk-6-source packages depending on what you are using.
For the Sun JVM, sources will end up in /usr/lib/jvm/java-6-sun-1.6.0.15/src.zip.
PS: I'd suggest to use Sun JDK and to set it as default with sudo update-alternatives --config java but this is more a side note.
In Preferences, make sure that under Installed JREs you are using a JDK and not a JRE.
I don't think that the JRE installs include the source attachment.
Try out apt-get install eclipse-source.
The following procedure will enable Java documentation to be available in Eclipse when you hover over some Java class. Download the Java Documentation (this is for version 6) from http://www.google.co.in/url?sa=t&source=web&ct=res&cd=4&ved=0CC0QFjAD&url=https%3A%2F%2Fcds.sun.com%2Fis-bin%2FINTERSHOP.enfinity%2FWFS%2FCDS-CDS_Developer-Site%2Fen_US%2F-%2FUSD%2FViewProductDetail-Start%3FProductRef%3Djdk-6u10-docs-oth-JPR%40CDS-CDS_Developer&ei=T-z3S87CAYuyNq3UweAF&usg=AFQjCNH54wkg50p7PJGmv6dEJd0zxXTGRA&sig2=Pv8-OZ7ZQEAsh89kUFhvUw This is a zipped file jdk-*-docs.zip ( * indicates the version number, for e.g., 6u18 which implies Java Version 6.18). Open Eclipse. Click on Window > Show View > Javadoc Right click on the Javadoc console. Select Open Input. Click "Change Attached Source". Select "External File". Navigate to the directory in which jdk-*-docs.zip exists. Open it. And there you have it - the entire documentation available to you at your fingertip(mousetip?).
Download Java sourece.
i get it from http://download.java.net/openjdk/jdk8/
2.Go to Window > Preferences > Java > Installed JREs
Select the installed JDK and double click on it, a edit JRE window will get open.
select rt.jar click add source and and select the patch where you have downloaded java source in step 1.
then exit by clicking OK/ Finish

Categories

Resources