Skip to main content

Greenville Java Users Group

Learning Java

Last modified: 2016-02-06

Home

Why Java?

  • Perhaps the best thing about Java is the JVM. The JVM (Java Virtual Machine) has allowed the Java language to run on any hardware and OS (operating system) since 1996. It has a tremendous array of tools, utilities, and packages that can run a web server, send email, or do just about any task you can imagine. Languages like Clojure, Scala, and Groovy are also built on top of the JVM and are compatible with Java and each other (to varying degrees).
  • Android apps are written in Java.
  • Knowing Java can help you understand the internals of other JVM languages.
  • Java has a strong static type system with some type inference.
  • Javadoc turns comments in your code into a web site describing your API.
  • Automatic memory management (unlike C).
  • Namespaces (package folders and class files) and Scoping rules that limit the visibility of your classes, methods, and fields.
  • "Evolution, not Revolution" means that a Java program from 1999 can probably still run on a modern JVM without being recompiled!
  • Java is Opinionated. Many of the "features" that made C++ code difficult to maintain - the preprocessor (macros) and operator overloading - are not allowed in Java. Java has annotations that allow safer “lite” versions of those features.

Java's Sweet Spot

Java is best for large projects involving 3 or more person-years of effort. It gives you many tools to manage complexity and refactoring (reorganizing a large code base without changing the functionality). Instead of throwing out spaghetti code when it becomes too complicated, you can reduce the visibility of the various pieces of code, a little at a time, until they are encapsulated to the point that each piece only sees the interface of the other pieces, not their implementations.

Beginner Resources

Taste your "first cup" of Java with the Oracle Java Tutorials

The Java API (Application Programming Interface) reference of language features is the primary reference you'll use. Javadoc is a great tool that turns comments in your code into a web site like this. In fact, this web site is built from the source code for Java itself!

Also see the tool docs (click on the colored boxes for javac - the Java compiler, javadoc, etc.)

Java is designed to be readable, but it doesn't hurt to start off following a style guide. Google's Java Style is probably most representative of modern best practices (see note about "Effective Java" in the Intermediate section below).

Integrated Development Environments (IDE's)

Though there is a Java mode for emacs, vim, gedit, and every other text editor, most Java programmers use an IDE that provides additional tools for navigating large code bases and refactoring. Some still use the command line for builds and treat the IDE as a smarter text editor. Others use the IDE for all tasks and eschew the command line altogether.

IntelliJ IDEA

This has gained popularity in recent years for its powerful refactoring tools. If you put your cursor on a method or variable name, CTRL-B takes you to where it was defined. If you set it up right, it will even take you into the source code of any open source tool (including the Java language itself). I think CTRL-U goes up to the interface of an overridden method, which is also really useful.

Netbeans

Netbeans is the simplest of the common IDE's, and is closely associated with GlassFish.

Eclipse

For a while, this was the most popular open-source Java IDE. Many vendors like IBM and WebLogic built huge projects around it.

Additional Tools

Maven is the standard build tool. Some other tools assume that you use it, so you might as well start with it. IntelliJ recognizes maven projects. If that's too strict for you (it's very weird for web applications), Gradle is ideal for those who want their build to be infinitely customizable and flexible.

JUnit is the standard testing framework that basically everyone uses. Testing is such a great way to prevent bugs that many have developed a religious fervor for it. How you use it is up to you, but unit testing is an important part of maintaining any code base in the long term.

The Java world tended to use mercurial, but unless you're planning to build the Java programming language (it's open source after all), git has become more popular.

The most popular swiss-army-knife of (web) application development is Spring

If you come from Clojure, or use Java for the combination of functional programming and static type checking, UncleJim provides a type-safe version of the immutable Clojure collections.

There are so many other great tools: Tomcat, Netty, utilities for mail, generating PDF's etc. And that's not even mentioning Java Enterprise Edition (EE)!

Intermediate Java

When you get to intermediate level Java, the best book is "Effective Java" by Joshua Bloch. No other book says more about style or has more sound advice. Glen has it open on his desk more than any other book.

Angelika Langer has the most practical advice about using Generics. Her blog made sense to Glen when nothing else did.

Advanced Java

An excellent advanced book is "Java Concurrency in Practice" by Brian Goetz.

Other JVM Languages
  • Clojure
  • Scala
  • Groovy started out as "Ruby for the JVM" and has found a niche as the language used with the Gradle build tool.
 
 
Close
loading
Please Confirm
Close