33

I am new to Java and trying to learn more about it. I studied the documentation and found the following for Java,

Java Docs

Are the packages listed here the same as standard libraries?

Sebastian Nielsen
  • 3,835
  • 5
  • 27
  • 43
Alan2
  • 23,493
  • 79
  • 256
  • 450

4 Answers4

54

Yes. That is the library that Java's creators have provided.

here is a list of things to know:

  • java.lang is for all the basic classes that are actually imported automatically (implicitly) because it is all the basic ones (String, Integer, Double, etc)
  • java.util contains all your data structures you learned in school and more. Read the documentation, and the more you know and practice, the better
  • java.io for file reading. Look into java.util.Scanner for simple file reading, but for any more complicated, low level file reading info, use java.io, its built for efficiency, while Scanner is for simplicity
  • java.math if you ever need to use arbitrary precision values (built-in in python, not in java)
  • java.net for sockets, connections, etc
  • javax.swing for GUI, which is an extension of the older java.awt

Hope that helps.

Kaushik Shankar
  • 5,491
  • 4
  • 30
  • 36
  • Are these two the most common of the libraries. Say for a simple program to handle some file input output and the console. What libraries would I need to consider using? – Alan2 Jun 03 '12 at 08:20
  • 12
    In _Effective Java_, Josh Bloch -- who wrote most of these libraries in the first place -- advises that you should know all of `lang` and `util`, and most of `io`. – Louis Wasserman Jun 03 '12 at 17:33
  • Completely agree, but honestly, those are just the basics. Everyone **needs** to know them. I would also strongly suggest the Network package because people need to do that stuff ALL the time now. And the Swing Framework because it's easy for GUI applications like games or something. – Kaushik Shankar Jun 04 '12 at 22:08
3

Yes they are the same. This library is also downloadable if you want to view it offline. Also there should be a src.zip file in your java installation files. On unzipping it you will find the source code of all the standard library classes. Also the Java Language Specification should help you.

Surender Thakran
  • 3,958
  • 11
  • 47
  • 81
  • Thanks for the link. When people code simple java programs are there some key libraries that are almost always included? – Alan2 Jun 03 '12 at 08:19
  • @Gemma If you are using an IDE like Eclipse, it will tell you which ones you have to include. Essentially, you import what you need and not more. – Jochen Jun 03 '12 at 08:20
  • @Gemma: The `java.lang` package is the default package which will be implicitly included in every code you write, if thats what you are asking. As you move onward you will learn to use other libraries/packages like `java.util`, `java.io` etc. – Surender Thakran Jun 03 '12 at 08:21
  • @Gemma: i would suggest not to jump ahead of youself and worry about packages. Pick a simple good book and it will guide you through all the libraries. – Surender Thakran Jun 03 '12 at 08:25
3

When you install Java, there will be a .zip file which contains the source of the standard library called, src.zip in root folder.These are the standard library.

UVM
  • 9,776
  • 6
  • 41
  • 66
  • As the name suggests, that zip contains the sources of part of the standard library, but this is NOT the bytecode that you can import and use. – Jochen Jun 03 '12 at 08:22
1

In Java 9+, javafx replaces javax as the main UI library:

  1. Is JavaFX replacing Swing as the new client UI library for Java SE?

    Yes. However, Swing will remain part of the Java SE specification for the foreseeable future, and therefore included in the JRE. While we recommend developers to leverage JavaFX APIs as much as possible when building new applications, it is possible to extend a Swing application with JavaFX, allowing for a smoother transition.

JavaFX FAQ - Oracle.

llf
  • 610
  • 10
  • 11