What Is JMH (Java Microbenchmark Harness) and How to Use It
JMH is the OpenJDK tool for accurate Java microbenchmarks. See why manual timing fails, how to set it up with Maven, and how to read the results.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
JMH is the OpenJDK tool for accurate Java microbenchmarks. See why manual timing fails, how to set it up with Maven, and how to read the results.
Java performance testing covers load, stress, spike and soak tests. See which tools to use, including JMH, JMeter, Gatling and JFR, with working examples.
Assert exceptions with the framework helper, such as assertThrows or pytest.raises, and check the type plus one stable detail instead of using try-catch.
BDD turns requirements into shared, executable examples written in plain language. Learn Given-When-Then, Gherkin, Cucumber and how BDD relates to TDD.
TDD means writing a failing test first, then the code, then refactoring. See the cycle with a Java and JUnit 5 example, plus benefits and limits.
Java 19 previewed virtual threads, record patterns and pattern matching for switch. See each feature, example code and its status today.
A Java record is an immutable data carrier with a generated constructor, accessors, equals, hashCode and toString. See how to declare, validate and pattern match them.
The non-sealed modifier lets a permitted subclass of a sealed type be extended by any class again. See the rules, examples and trade-offs.
Java SE is the core platform, Jakarta EE adds enterprise APIs, and Java ME targeted small devices. See what each includes and which one fits your project.
Build a Jakarta EE web application with Maven, servlets and JSP, understand the javax to jakarta rename, and deploy the WAR to a compatible server.
The Java Servlet API lets Java classes handle HTTP requests inside a container like Tomcat. Learn the lifecycle, key types and the move to jakarta.servlet.
GET reads data and is safe, idempotent and cacheable. POST sends data in the body to create or process something. Here is when to use each.
Use the Jakarta Servlet HttpSession safely: login and logout, timeouts, secure cookie flags, session fixation protection and sessions across servers.
HttpServletRequest reads what the client sent and HttpServletResponse writes the reply. See the key methods, examples and common mistakes.
@PathVariable maps placeholders such as {id} in a URL to method parameters. This answer covers optional variables, regex patterns, validation and @RequestParam.
Configure multipart support in Spring and Spring Boot, accept MultipartFile in a controller, validate and store uploads and handle size errors.
@ResponseBody makes a Spring handler write its return value to the response body. See method and class usage, JSON error handlers and the ResponseEntity trade-offs.
Annotate controllers with @RestController or @ResponseBody and Spring serializes return values with Jackson. Covers setup, ResponseEntity and troubleshooting.
@RestController marks a class whose methods write return values to the response body, usually as JSON. Compare it with @Controller and see Spring Boot examples.
Learn SOLID in Java with short, modern examples using records and interfaces, and when each principle helps or goes too far.