Since you specifically mentioned JDK, I think it's allowed to mention an API which actually isn't available in the JRE and is also less known among most of us: javax.tools.
Here's a full demo snippet:
package test;
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
import java.net.URL;
import java.net.URLClassLoader;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
public class Test {
public static void main(String[] args) throws Exception {
// Prepare source somehow.
String source = "public class Test { static { System.out.println(\"test\"); } }";
// Save source in .java file.
File root = new File("/test");
File sourceFile = new File(root, "Test.java");
Writer writer = new FileWriter(sourceFile);
writer.write(source);
writer.close();
// Compile source file.
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, sourceFile.getPath());
// Load compiled class.
URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() });
Class<?> cls = Class.forName("Test", true, classLoader); // Prints "test".
}
}
Useful? Not sure. Interesting? Yes, interesting to know :)
For the remnant, I like the Collections, Reflection, Concurrent and JDBC API's. All of which are already mentioned before here.