• Uncategorized

About java : Is-there-an-Java-API-viewer-on-command-line-like-man-for-c-and-ri-for-ruby-closed

Question Detail

Is there an Java API viewer on command line?

I have been using man for C programming and ri for Ruby programming. Both of them seems very convenient for me, and now I am looking for something alike for Java API.

I apologize if this question has been raised before. I did many Google searches but no result shows up. I think I might have been using the wrong terms.

Question Answer

As part of the JDK, you will also receive the javap utility that allows you to see method signatures in a java .class file.

javap myClass

For java API, you can use

javap java.lang.Integer

If you are a vi fanatic, use this tweak to see the method signature on the class under cursor with the following addition to your ~/.vimrc.

let $jre='/cygdrive/c/jdk1.6.0_21/jre'  
map tt yy:tabnew ^R^W^M  
map + tt:set ft=java^M!!javap -public `grep .*%$ $jre/lib/classlist`^M  
  1. Characters preceeded by caret like ^M need to be typed using Ctrl+V then Ctrl+M
  2. javap needs to be in your system path
  3. Use your own jre location in place of this
  4. Finally, since this is tested using cygwin, you may need to do some touch ups

Another way is to use a text-based browser. See:
Look up javadoc Help file from Vim [Unix Only]

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.