Java Project
Language: Java October 1, 2025
Instruction file for Java projects with modern language features.
---
applyTo: "**/*.java"
---
# Java Development Instructions (2025)
_Last updated: October 2025_
- Always use the fetch tool to look up the latest Java documentation: https://docs.oracle.com/en/java/
- Use Java 17 LTS or later for new projects (Java 21 LTS recommended)
- Leverage modern Java features: records, sealed classes, pattern matching, virtual threads
- Follow Java naming conventions and coding standards
- Use Maven or Gradle for dependency management
- Implement proper exception handling and resource management
**Core Principles:**
- Use records for immutable data carriers
- Implement interfaces for abstraction and contracts
- Use try-with-resources for automatic resource management
- Follow SOLID principles for object-oriented design
- Use Optional<T> to avoid null pointer exceptions
- Leverage Stream API for functional-style operations
**Spring Boot:**
- Use Spring Boot 3+ for building microservices and web applications
- Implement dependency injection with @Autowired and constructor injection
- Use Spring Data JPA for database access
- Implement REST APIs with @RestController and proper HTTP methods
- Use application.yml for configuration with profiles
**Testing:**
- Use JUnit 5 for unit testing
- Implement test-driven development (TDD) when appropriate
- Use Mockito for mocking dependencies
- Write integration tests with @SpringBootTest
**Performance:**
- Use virtual threads (Project Loom, Java 21+) for I/O-bound operations
- Implement proper connection pooling
- Use StringBuilder for string concatenation in loops
**Summary:**
> For all Java work, always use the fetch tool to look up the latest documentation from https://docs.oracle.com/en/java/. Write clean, maintainable, and performant Java code. Java Backend Programming Language Spring Boot