steering_docs/java-tech.md
# Build and Package
mvn clean compile # Compile source code
mvn package # Build with dependencies
mvn clean package # Clean and build
# Testing
mvn test # Run all tests
mvn test -Dtest=ClassName # Run specific test class
mvn test -Dtest=ClassName#methodName # Run specific test method
# Execution
java -cp target/PROJECT-1.0-SNAPSHOT.jar com.example.Main
mvn exec:java -Dexec.mainClass="com.example.Main"
{Service}Action.java (e.g., S3ListBuckets.java)Hello{Service}.java (e.g., HelloS3.java){Service}ActionTest.javaHello{Service}.java class with main methodcom.example.s3)import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.core.exception.SdkException;
import software.amazon.awssdk.services.s3.model.S3Exception;
public class ExampleClass {
public void exampleMethod() {
try (S3Client s3Client = S3Client.builder().build()) { //For Hello examples, use Sync service clients. For Scenario examples or working with service client, use the Java Async client.
// AWS service call
var response = s3Client.operation();
// Process response
} catch (S3Exception e) {
// Handle service-specific exceptions
System.err.println("S3 Error: " + e.awsErrorDetails().errorMessage());
throw e;
} catch (SdkException e) {
// Handle general SDK exceptions
System.err.println("SDK Error: " + e.getMessage());
throw e;
}
}
}
@Test, @BeforeEach, @AfterEach)@Tag("IntegrationTest") or similarsrc/
├── main/
│ └── java/
│ └── com/
│ └── example/
│ └── {service}/
│ ├── Hello{Service}.java
│ ├── {Service}Actions.java
│ └── {Service}Scenario.java
└── test/
└── java/
└── com/
└── example/
└── {service}/
└── {Service}Test.java
Before creating Java code examples:
coding-standards-KB for "Java-code-example-standards"Java-premium-KB for "Java implementation patterns"