A Docker-based Java development environment for experimenting with Java standard library and third-party libraries. This sandbox comes pre-configured with:
- Java 17 (Eclipse Temurin)
- Gradle for dependency management
- Popular libraries:
- OkHttp for HTTP requests
- Jackson for JSON processing
- Lombok for reducing boilerplate
- JUnit for testing
- Build the Docker image:
docker build -t java-sandbox .- Run the container:
docker run -d --name java-sandbox -v $(pwd):/app java-sandbox- Execute Java code inside the container:
docker exec -it java-sandbox gradle run- Write your Java code in the
src/main/java/com/sandboxdirectory - Add any new dependencies to
build.gradle - Rebuild the container if you modify the
build.gradle - Use the provided
HttpExample.javaas a template for your experiments
The project includes a sample HttpExample.java that demonstrates:
- Making HTTP GET requests
- Making HTTP POST requests with JSON body
- Using OkHttp client
- Basic error handling
- The container stays running, so you can execute multiple commands
- Use
docker exec -it java-sandbox /bin/bashto get a shell inside the container - Add new dependencies in
build.gradleas needed - Use
gradle cleanto clean the build directory - Use
gradle buildto compile and run tests - Use
gradle dependenciesto view the dependency tree