File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java API searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java API searching" Watch "Java API searching" New topic

Java API searching

Pal Sudarshan
Ranch Hand

Joined: Jun 10, 2004
Posts: 52
Hello All,

My question: How should one search the SUN's API? Say, for example, I want to know if a method already exists in Java API. Then how should I search the Java API? How would I know which class and package that method more likely belongs to?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Honestly, the real answer is experience. The only way to learn your way around is by reading, studying, and using the APIs. There's no magic bullet here.

[Jess in Action][AskingGoodQuestions]
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118

If you mean "find a method that does this" then yeah, only way is through experience (or asking someone else with experience)
[ June 25, 2004: Message edited by: Darin Niard ]
siva raju
Ranch Hand

Joined: Oct 10, 2003
Posts: 37
If you could also guess the method name close enough, go to the java api index, and check out the methods. I have been lucky this way sometimes.

Siva<br />-----<br />SCWCD 1.4, SCJP 1.4, SCBCD(Preparing), CCNA
Nitin Shivaram
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
Try using the Java SDK WinHelp, if you know the method name, it's a Walk in the park.

Get Java SDK WinHelp from Here Java SDK WinHelp

Nitin S<br />Sun Certified Java Programmer for the Java 2 platform.<br />Tekmetrics Certified Java Programmer For the Java 2 Platform.
sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
At the risk of engendering hatred aimed at yours truly...I find that sometimes I can actually intuit this sort of thing.

This sounds a LOT more pompous and arrogant than it really is...let me explain. First, you do need a good deal of experience with the basic package structure of the JDK and the most significant classes within those packages. This will not only give you the basic knowledge of the main APIs but a feel for how things are organized. (I admittedly also benefit from having followed the history of the development of these APIs, so I have quite a bit of knowledge that one could probably only attain by having worked with every JDK since 1.0...but I don't think this is that big a factor.)

Second, assume the JDK is perfect and all-encompassing.

Seriously. Assume it does everything you need it to do in the best, most elegant way you can think of, and puts that functionality in the place that makes the most sense to you based on what you know about the JDK packages and classes. Then go there, and expect it to be there. It often is. Sounds crazy, but Java's not that bad once you have the basics down. You will miss a lot at first, but the good thing about doing this is that you are actively engaging the APIs on an intellectual level, which means that your search through the APIs will be driven by logic, which means it will be connected to you at some unconscious, deep-seated emotional level because of the basic human need to be right. And quite often, when you miss, it will be not because the JDK is not perfect, but rather because it's in a more perfect place than you could think of. And when you do learn where it is, and it dawns on you why that's a more perfect place, your knowledge of the APIs is bolstered and you engage in what I believe is called a virtuous cycle.

As opposed to random, brute-force stabs at locating functionality using the function index...which is a vicious cycle of degenerating comprehension because it encourages a view of the APIs that is more library like in structure than OO-like.

I agree. Here's the link:
subject: Java API searching
jQuery in Action, 3rd edition