• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with the APIs?  RSS feed

 
Dave McQueen
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting very frustrated with the Java APIs. As a beginner to java I won't know what classes and methods are available - or even if they exist already - unless I memorize the entire API. Given that I'm not that bright, can someone tell me how to find a method that does what they want it to (so you don't have to recreate it unwittingly) without already being aware that it exists or where it is? (I'm speaking generally here but have encountered this quite a lot!!).
Surely there must be an application that helps you define what you'd like the method to do (i.e parse strings, ints or create database connections, or load xml file, return a String etc) and then returns a list of possible matches?
Isn't Java supposed to be reusable? How can you reuse something that you don't already know exists to be used in the first place? I think I must have missed something to not understand this and would appreciate your help!
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very valid remark. Sun's online API documentation is excellent, but for the most part it is not task centric. Very little documentation on the net anywhere is, in my opinion. I have often bemoaned knowing that my task was very simple, but spent a long time zeroing in on the correct info. With time and experience, you will become better at using the API, you will get a feel for what classes will likely have the answers you need.

You may have better luck searching the Java Tutorial. http://java.sun.com/docs/books/tutorial/

You might also try using Google, Sun isn't the only place that tells you how to use java. If you are interested in parsing strings, or squaring a circle, then Google "java parse strings', or "how to square circle java" and see what comes up. experiment.

 
Dave McQueen
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response Fred. Particularly the part about "Very valid remark". I was worried I was asking a very stupid question. It seemed wierd that there wasn't some mechanism to make the library more "task centric" as you put it and was certain I must be missing something.
Hopefully there's some talented developers reading this that could create the Task Centric Holistic ApI or Tchai (ok "holistic" isn't the best h-word but it's the best I can come up with at short notice to make the anagram work!!) so that my job is easier in the future!
Thanks for your suggestions too.
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Example Depot would fit your "Task Centric Holistic ApI" requirement. It's a searchable collection of Java source snippets. If I can't find something there, I try searching this site. If I can't find it here, I search the web in general.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get yourself a decent Java IDE. I use Eclipse which helps greatly in this regard. It's not a mind reader but you can put a "." after any object and press crtl + space to see a list of all methods available for that object. This includes the method names, thier input parameters, and the return values. This is usually enough for me to figure out what method I need to use. For instance you have a String object and you want to change it into a byte[]. After typing the dot and getting the list to come up a detail like, "byte[] toByte()" would be enough detail for me to know that's the method I need.

By the way, I made up the method name and details, it was just an example (for my fellow nitpickers )
 
Victor Ewert
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Fred. What I usually do is try google, or try searching on a forum (like this one). I can usually find what Classes are involved in the solution, and then I use the Java API to get the details. Over time you get to know what the Java API can do for you and what it can't.

Victor Ewert
Ewert Technologies
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very disappointed, but Google didn't know how to square the circle

However much I like Eclipse, Brian, I still think the raw beginner should avoid IDEs. They have enough to learn with Java, without having to learn the IDE too.

The other chaps have very valid points. The API documentation is directed at
advanced (not novice) programmers
so it is not intended to be task-centric.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An intro to Java book will also cover the common classes in a more task oriented way. After a while, you know what class to look at for types of tasks. That's when the API becomes useful.
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave McQueen wrote:I'm getting very frustrated with the Java APIs. As a beginner to java I won't know what classes and methods are available - or even if they exist already - unless I memorize the entire API. Given that I'm not that bright, can someone tell me how to find a method that does what they want it to (so you don't have to recreate it unwittingly) without already being aware that it exists or where it is? (I'm speaking generally here but have encountered this quite a lot!!).
Surely there must be an application that helps you define what you'd like the method to do (i.e parse strings, ints or create database connections, or load xml file, return a String etc) and then returns a list of possible matches?
Isn't Java supposed to be reusable? How can you reuse something that you don't already know exists to be used in the first place? I think I must have missed something to not understand this and would appreciate your help!


I see your point, since I'm a beginner at Java myself, and, I find the API to lack real-world and concrete applications, hence, I have to "do a lot of math and logic" in order to try to work my way though the simplest of solutions. The following might help:

http://www.exampledepot.com/egs/index.html **
http://www.devarticles.com/c/b/Java/
http://www.mindview.net/Books/TIJ/
http://www.ibm.com/developerworks/views/java/libraryview.jsp?search_by=diagnosing%20java%20code:
http://www.netbeans.org/kb/articles/jAstrologer-intro.html
http://www.apl.jhu.edu/~hall/java/FAQs-and-Tutorials.html
http://www.leepoint.net/notes-java/index.html
http://xahlee.org/java-a-day/java.html
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html
http://java.sun.com/javase/6/docs/platform/serialization/spec/serialTOC.html
http://www.java.net/
http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html
http://www.particle.kth.se/~lindsey/JavaCourse/Book/courseMap.html
http://flint.cs.yale.edu/cs112/help/java-prog-faq.html
http://www.faqs.org/faqs/computer-lang/java/programmers/faq/
http://mindprod.com/jgloss/compiler.html
http://support.objecteering.com/objecteering6.1/help/us/java_developer/toc.htm
http://www.java2s.com/Code/Java/CatalogJava.htm **
http://leepoint.net/notes-java/index.html
http://java.sun.com/javaee/5/docs/firstcup/doc/p2.html#gcqyb - JavaEE
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/GettingStarted2.html#67955 ** - Setting up
http://www.research.ibm.com/ninja/#sc99
http://www.dickbaldwin.com/java/Java020.htm
http://www.regular-expressions.info/java.html
http://www.szc001.com/ - This blog is written by a friend of mine who has an interesting sense of humour and a good knowledge of a number of languages

NOTE: Those marked with ** are the ones I think are easier to follow because they include code snippets.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
download the java apidocs, and if your IDE doesn't have a good 'help' which allows you to search the apidocs,
download this windows-help-format program
http://www.allimant.org/javadoc/index.php

as an example, you'd type in String, click 'List Topics' then the item for the String class, which would then show the String apidocs,
and from there its just a matter of perusing the "Method Summary" and "Methods inherited from ..." (don't forget this part)
 
Dave McQueen
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for your responses! Didn't expect this much help so it's very much appreciated.
Cheers!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a historical note, when Java 1.0 appeared, there were only a half-dozen packages in the API! From memory, I think the complete list was

java.applet
java.awt
java.awt.peer
java.io
java.lang
java.net
java.util

There were perhaps two hundred classes altogether. The API format worked really well! You could scroll through the index of all classes -- all on one page! -- and spot the useful ones. And of course, it was easy to know what each package was for (except java.awt.peer, which, as you'll notice, isn't in the public documentation anymore. Its inclusion had really been a mistake.)

Java 1.1 doubled the size of the API, and people did complain about that. But of course, all the new stuff was great, so we learned to live with it. Subsequent versions have doubled it again a few more times, and I'll agree, the original format no longer serves all the purposes it once did. But it started out as a fine idea!
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I still like it a lot better than Microsofts .NET Framework Class Library Reference. Try searching a specific class, field or method in that one. The MSDN search at the top is not restricted to the .NET API; it searches the entire MSDN.
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:And I still like it a lot better than Microsofts .NET Framework Class Library Reference. Try searching a specific class, field or method in that one. The MSDN search at the top is not restricted to the .NET API; it searches the entire MSDN.


I'm sorry but I don't have enough asprin to search the MSDN. I find it a very convoluted mess....
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll say this about the API docs. They are very well organized considering the volume and interrelationships of the material.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!