Understand the JVM so you can love Clojure
The number of undefined terms in documentation can be infuriating. What is a CLASSPATH? What's PermGen? Do you get lost in the massive standard library? Have you ever given up on an exception because you were crushed under the weight of the stack traces? Do you hate using Java directly instead of a nice Clojure wrapper? The number of things to learn just to start using Clojure is enormous.
The truth is, the JVM is a big, complicated system that has evolved over time. Clojure sits on top of it like a rider on a horse. When a Java programmer gets into Clojure, it's all gravy. They already know the ins and outs of Java and the JVM, so to have a sweet language like Clojure to control it, they squeal with joy. But if you don't have that JVM experience, the squeals are not joyful. It is definitely confusing.
Wouldn't it be nice to skip 10 years of Java experience and see what the experts see?
Sure, you're not going to become an expert overnight. That's not what I'm talking about. However, some of the concepts are more important than others. In fact, the stuff that a Clojure programmer needs to use most days is quite small. If you learn just those, you'll be playing on easy mode. Further, you can learn the tricks experienced Java people use to find out what they don't know. It's often as easy as googling the error message.
Introducing JVM Fundamentals for Clojure
This course teaches you the hands-on, nitty gritty details of the JVM and Clojure/Java interop that you would pick up after many years of programming Java. It combines videos with reference sheets to give you easy access to the accumulated skills of years of experience. With this course, you won't have to worry about stack traces, JVM options, or the standard library again.
- Calling methods and accessing fields.
- Class and method introspection.
- Reading Javadocs.
- Handling and raising errors and exceptions.
- Manipulating Java arrays.
- Dealing with dates and times.
- Understanding the classpath.
- The anatomy of a JAR
- Controlling JVM memory usage.
- Running java and Clojure programs from the command line.
- Doing I/O on the JVM
- Helpful macros for manipulating stateful objects
What people are saying
I just wanted to say thank you for making a lesson out of my suggestion. I watched it today and think it is really excellent. JVM Fundamentals is really a jewel of learning material. Congratulations and thanks for your great work.
JVM Fundamentals for Clojure
Want this course?
Love it or leave it guarantee
If you don't learn as much from this course as you thought, just ask for a refund within 30 days and I'll give you your money back.
1. Understanding the abbreviations of the Java world—JVM JRE JDK
Ever get confused with what the JVM, JRE, and JDK are and what are in them? This lesson runs through these abbreviations. They're actually easier than they sound.
2. Choosing a JDK--licensing, support, and upgrade schedule
Oracle has recently changed their licensing terms. Before, we recommended using Oracle's JDK build. It was free for commercial purposes. But it's no longer free. Now we recommend using AdoptOpenJDK.
This lesson goes over the structure of the Javadocs and some tricks for making the most of them.
4. Java Dependencies
Java has had a way to package compiled code and resources and share them around since almost the beginning. It's called the JAR (Java Archive). Combine that with an artifact, versioning, and dependency management system (called Maven), and we have a complete dependency management system.
5. Leiningen and Dependencies
Leiningen hooks into the Maven dependency management to provide dependencies for Clojure. We take a look at how Leiningen does that. We also see how to 1) find conflicts in the dependencies; and 2) find old dependencies that can be upgraded.
7. Running Java with options
This lesson goes over some of the most common commands for running java on the command line.
8. Fields and Methods
Everything in Clojure is based on Java Objects. That means it all boils down to methods and fields on objects and classes. When you're interfacing with a Java library, including the standard library, you will need to access methods and fields all the time. This lesson covers the normal and most common ways of calling methods and accessing/changing the state of objects.
9. Classes and Reflection
Java has a good story for reflection: just ask the object for its class and ask the class for a list of methods. Voilà! You know what methods you can call. This lesson demonstrates reflection with some examples.
10. Import form
When we need to refer to Java classes, we need to import them in the ns declaration. There are a few things you should know about doing that. This lesson covers the basics, a couple of gotchas, and some nice properties of the import form.
11. Exceptions and Errors
In this lesson, I go through throwing, catching, and extracting information from exceptions and errors.
12. Java Arrays
Every now and then you'll have to use Java arrays. Usually it's because a method returns an array. But sometimes you'll have to create one. This lesson goes over just that--consuming and creating Java arrays in Clojure.
13. Java I/O
In this video, we go over some common patterns for using the java.io package and how the clojure.java.io namespace handles the most common cases for you.
In this lesson we look at
java.io.File and how the
clojure.java.io namespace makes it easy to use.
15. Monitoring Tools
We look at several tools for querying the JVM so that we can monitor it.
16. Cloud Monitoring
If you're running a system in production, you'll want to keep an eye on it 24 hours per day. There are now cloud monitoring options that collect information from your JVM all the time and will send alerts.
17. Creating a Clojure Library for use in Java
Have you ever wanted to solve a problem with your Java app by using Clojure? Have you ever wanted to "sneak in" a dependency on the Clojure JAR but didn't know what to do with it once it was there? This lesson shows you how to create a Clojure library that you can use from Java.
18. JAR Anatomy
Like a surgeon, we dissect JAR files to figure out how they tick. We also take a look at the
jar command and how to use it to create, extract, and update JAR files.
21. Java Threads
We look at creating and starting threads on the JVM and how to cleanly shut everything down.
22. Dealing with temporary files
Creating temporary files on the JVM is not hard, per se, but it is not obvious, either. It's done with a very Java-esque style. In this lesson, we go through how to create a temporary file and how to create a temporary directory.
23. Logging on the JVM
A lot of people requested this lesson. How do we set up logging on the JVM? It turns out that it's not that hard. We can do it with a few lines of code. In this lesson, we see how to use logging in libraries and in applications.
24. Creating Java classes with gen-class
Clojure comes with a set of tools for creating Java classes (compiled to
.class files) using pure Clojure. It's called
gen-class. You can add
:gen-class directives to your namespace declarations.
25. Creating Java interfaces with gen-interface
Clojure comes with a tool called
gen-interface for building Java interfaces without writing any Java. We look at how to make a new interface including defining its methods.
26. Mixed projects (Clojure with some Java)
gen-interface, sometimes you need to write some Java. In this lesson, we see how to integrate Java source files into Leiningen and Boot projects.