Sign inSign up

michaeldisalvo/jvm-dev-container

By michaeldisalvo

•Updated 4 months ago

An all-purpose JVM devcontainer. Can be used for Clojure, Scala, Java, and Kotlin.

Image
0

430

michaeldisalvo/jvm-dev-container repository overview

A valid devcontainer.json⁠ configuration for this Dockerfile.

⁠All-Purpose JVM VS Code Dev Container

A complete VS Code dev container setup for JVM development with Java 25, Maven, Gradle, SBT, and Kotlin.

⁠Prerequisites

⁠Getting Started

⁠Quick Start Script

View the Quick Start guide⁠ This provides a script to bootstrap your repo

  • Give it a GitHub repository reference
  • It will then clone the repo and copy these files into it directly
⁠On Dockerhub
⁠1. Open in Dev Container
  1. Clone or create your JVM project with this .devcontainer folder in the root
  2. Open the project folder in VS Code
  3. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) and select "Dev Containers: Reopen in Container"
  4. Wait for the container to build and start (first build takes 5-10 minutes on first run)
⁠2. Create a New Project

Choose your language and build tool:

Leiningen + Clojure:

lein new app my-clojure-app
cd my-clojure-app
lein repl

Then use Calva (the Clojure extension) to connect to the running REPL:

  • Press Ctrl+Alt+C then Ctrl+Alt+C to connect
  • Select the running REPL session

Maven + Java:

mvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
cd my-app
mvn clean package

Gradle + Java:

gradle init --type java-application --dsl groovy --package com.example
cd app
gradle build

Kotlin + Gradle:

gradle init --type kotlin-application --dsl groovy --package com.example
cd app
gradle build

Scala + SBT:

mkdir my-scala-app && cd my-scala-app
sbt new scala/scala-seed.g8

⁠What's Included

  • Java 25 LTS - Latest stable Java version
  • Leiningen 2.10.0 - Clojure project management tool
  • Calva - Best-in-class Clojure development extension for VS Code
  • Paredit - Structural editing for Clojure code
  • Maven 3.9.8 - Build automation and dependency management
  • Gradle 8.9 - Advanced build automation with Kotlin DSL support
  • SBT 1.10.1 - Scala build tool
  • Kotlin 2.3.21 - First-class Kotlin support
  • Git & GitHub CLI - Version control tools
  • Extension Pack for Java - Full Java IDE support
  • Maven cache mount - Persistent .m2 cache
  • Gradle cache mount - Persistent .gradle cache
  • SBT cache mount - Persistent .sbt cache

⁠Forwarded Ports

The container forwards these ports for convenient access:

  • 3000 - Application server (default)
  • 5005 - Java remote debug port
  • 8080 - HTTP server (e.g., Tomcat, Spring Boot)
  • 8888 - Local development server
  • 8890 - REPL communication
  • 9000 - SonarQube or other analysis tools

⁠VS Code Extensions

Automatically installed:

  • Extension Pack for Java - Java IDE with debugging and testing
  • Calva - Clojure IDE
  • Arrange It - Code formatting
  • Maven for Java - Maven support in VS Code
  • Gradle for Java - Gradle build support
  • Kotlin Language - Kotlin support and debugger
  • Metals - Scala IDE with LSP support
  • GitHub Copilot - AI assistance (optional, requires GitHub account)
  • GitLens - Git history and blame visualization

⁠Useful Commands

⁠Verify Installation
java -version
lein --version
mvn --version
gradle --version
sbt --version
kotlinc -version
⁠Leiningen
lein new app project-name
lein test
lein uberjar
lein repl
lein clean
⁠Maven
mvn clean install
mvn test
mvn spring-boot:run
⁠Gradle
gradle build
gradle test
gradle run
gradle bootRun  # For Spring Boot
⁠Kotlin
kotlinc -help
kotlinc Main.kt -include-runtime -d Main.jar
java -jar Main.jar
⁠Scala + SBT
sbt compile
sbt test
sbt run
sbt console  # Interactive Scala REPL
⁠Java
javac MyClass.java
java MyClass
jar cf my-app.jar *.class

⁠Troubleshooting

⁠Container fails to build
  • Ensure Docker is running
  • Delete the .devcontainer folder from your VS Code workspace and rebuild
  • Check Docker logs: docker logs <container-id>
⁠Can't connect to REPL in Calva
  • Make sure the REPL is running: lein repl in the terminal
  • Try disconnecting (Ctrl+Alt+C Ctrl+Alt+D) and reconnecting
⁠Slow dependency downloads
  • Maven downloads are cached in /root/.m2
  • First build may take time; subsequent builds are faster
⁠Port already in use
  • Modify the port mappings in devcontainer.json under forwardPorts

⁠Customization

⁠Modify Java Version

Edit the FROM line in Dockerfile:

FROM eclipse-temurin:25-jdk-jammy  # Change 25 to 17, 11, etc.
⁠Remove Unnecessary Tools

To reduce image size, comment out tools you don't need in Dockerfile:

# RUN mkdir -p /opt/sbt && \  # Skip SBT if not using Scala
#     wget -q https://...
⁠Add More VS Code Extensions

Add extension IDs to the extensions array in devcontainer.json:

"extensions": [
  "ms-vscode.extension-pack-for-java",
  "your-extension-id"
]
⁠Change Default Port Forwards

Edit forwardPorts in devcontainer.json:

"forwardPorts": [3000, 5005, 8080, 8888, 9000, 9200]

⁠Resources

⁠License

This dev container configuration is provided as-is for development purposes.

Tag summary

Content type

Image

Digest

sha256:111da639c…

Size

467.1 MB

Last updated

4 months ago

docker pull michaeldisalvo/jvm-dev-container