[ACCEPTED]-how to find java classes?-class-library

Accepted answer
Score: 21

If you're new to Java (or programming), it's 77 going to be important to learn how to read 76 and understand the documentation in order 75 to become self-reliant -- it's the first 74 step to getting less dependent from other 73 people, and in most cases, will improve 72 your learning and programming speed.

The 71 following are some tips and suggestions:

Get to know the Java API Specification.

At 70 first, the Javadoc format of the API Specification 69 seem a little bit underpowered without any 68 search ability, but I've found that to be 67 that being able to browse the documentation 66 with a browser to be very powerful.

Since 65 the Javadocs are just HTML files, they can 64 be easily viewed and navigated in a browser, and 63 bookmarking pages are easy as well. Also, the API Specification is available for download, so 62 it not necessary to always go to the web 61 to get information.

As the documentation 60 is just web pages, using the Find feature 59 of the browser can find information quickly 58 in a page, and if that fails, using Google 57 or your favorite search engine to find documentation 56 is very fast and easy.

Google (or your favorite search engine) is your friend.

Need information on 55 the StringBuilder class? Try the following query:

stringbuilder java 6

The 54 first result will be the Java API Specification 53 page for the StringBuilder class. The tip is to append 52 the string "java 6" at the end of the 51 query and that seems to bring the API Specification 50 to the top most of the time.

Get comfortable with the structure of the API Specification.

The presentation 49 structure of the Javadoc tool is very nice and 48 logical:

|           |                   |
|  Packages |                   |
|           |                   |
+-----------+      Details      |
|           |                   |
|  Classes  |                   |
|           |                   |

The Javadoc is partitioned into 47 three frames.

  • Top-left frame: Listing of all the packages of the Java platform API.
  • Bottom-left frame: Listing of all the classes in the selected package.
  • Right frame: Details of the currently selected package or class.

Generally, looking for a class 46 starts from selecting a package from the 45 top-left hand frame, then looking for the 44 class in the bottom-left frame, and finally 43 browsing through the details on the right 42 hand frame. The idea is:

Package -> Class -> Details

The details in the 41 right hand frame for the classes and packages 40 are also very structured. For classes, the 39 structure are as follows:

  • Class name
  • Inheritance hierarchy
  • Implemented interfaces
  • Related classes
  • Information on and description of the class; usage examples.
  • Field summary
  • Constructor summary
  • Method summary
  • Field/Constructor/Method details.

When I'm looking 38 for information on a method, I will scroll 37 down to the Method Summary, find the method 36 I want, and click on that method name which 35 will jump to the Method Details.

Also, everything 34 about the class is documented in one page 33 -- it may seem like it is too much information 32 for one page, but it does make it easy to 31 get all the information you need about the 30 class from one location. In other documentation 29 formats, it may be necessary to flip between 28 multiple pages to get information about 27 several methods in the same class. With 26 the Javadoc format, it's all in one page.

Learn the Java Platform API

The 25 next step is to learn the important packages 24 of the Java Platform API. This will aid 23 in quickly finding classes from the huge 22 collection of classes in the platform API.

Don't worry, take it slow -- you don't need to learn everything at once!

Some 21 packages of interest are:

  • java.lang -- Contains the 20 classes such as String, System, Integer, and other that are 19 automatically imported in every Java program.

  • java.util -- Contains 18 the Java collections (such as List, Set, Map and their 17 implementations), Date, Random and other utilitarian 16 classes. This is probably the first package 15 to go to in order to find classes that will 14 be useful in performing common operations.

  • java.io -- Classes 13 concerning with input and output, such as 12 File, Readers and Writers and the various Streams.

  • java.awt and javax.swing -- For 11 graphical user interfaces, Java uses Abstract 10 Window Toolkit or Swing, and those two packages 9 are used to deal with GUIs in Java.

Knowing 8 where classes are and starting to get a 7 feel of where to look in the vast amount 6 of documentation will make it easier to 5 find information. It will probably take 4 a while to get used to it, but once you 3 get a hang of it, it should be much easier, and 2 you'll be able to find the information on 1 your own.

Good luck!

Score: 3

Most of the times if it is in the core of 17 the language ( that is not a 3rd party library 16 ) I use the following link:


Which list 15 all the classes in Java SE.

To know if the 14 class may work or not I try by pressing 13 Ctrl-F and guess what class would be the 12 appropiate.

Eventually with time, when you 11 get used to the classes there are, the search 10 will be easier.

For instance, let's say you 9 want to use an array:

Ctrl+F Array yields:


I 8 click on each one and see the documentation. Some 7 of them make no sense, some of them are 6 exactly what I need.

Sometimes it may not 5 work very straight forward. Lets way how 4 to create a Window:

Ctrl+F don't show JFrame 3 which is the correct answer, but it is just 2 matter of tunning your sense :)

I hope this 1 helps.

Score: 2

It depeneds what you mean. E.g. if you 7 want to know the location of an exact class 6 like "Where was BufferedReader again?", I 5 do a Google search on:

site:java.sun.com BufferedReader

If you want to know 4 how to do a task, e.g. "How can I read passwords 3 from the terminal without echoing?" (java.io.Console), sometimes 2 you can only figure it out for the first 1 time by asking for advice.

Score: 1
  • Are you looking for java libraries? Try google search , e.g. database connection pool java
  • Are you looking for classes inside the core java libraries? Install an IDE and look for classes, e.g. in Eclipse try Ctrl-Shift-T and type names: LinkedList . Note that in Eclipse you can also use wildcards, such as *List to get all classes with names ending in List;
  • Looking for a specific class inside a package? Try Sonatype's Maven repository, click advanced search, and in the new drop-down select class name.


Score: 1

I would recommend a book such as Java In A Nutshell which 3 is an excellent reference for the Java SE 2 API (note that it covers Java 5 only, but 1 that should be OK for most needs)

Score: 1

The Java tutorials, http://java.sun.com/docs/books/tutorial/, and the Java API, http://java.sun.com/javase/6/docs/api/, are 2 essential resources to find out how to do 1 something and with what classes.

Score: 1

I like to use DocJar.

There is even a plugin for 1 eclipse but I have not tried it yet.

Score: 0

I agree that the tutorials are good and 10 search engines in general are great (but 9 they now all lead you back to SO). Besides 8 the forums, one resource not to miss is 7 the programmers around you. If you are 6 part of a dev team or in a class, you can 5 get the answers you need or you can collaborate 4 on the search. It is often easier for a 3 human to help you if you are not exactly 2 sure you understand what it is you are looking 1 for.

More Related questions