Skip to content

applications(java): add shared instructions for variables with dots#899

Open
davlgd wants to merge 1 commit intomainfrom
davlgd-java-env
Open

applications(java): add shared instructions for variables with dots#899
davlgd wants to merge 1 commit intomainfrom
davlgd-java-env

Conversation

@davlgd
Copy link
Copy Markdown
Collaborator

@davlgd davlgd commented Mar 19, 2026

📝 What does this PR do?

This pull request standardizes and improves the documentation for environment variable injection in Java and Scala applications. The main update replaces previously scattered or inconsistent instructions with a single, shared content file that clearly explains how Clever Cloud injects environment variables for JVM-based applications, including details about variables with dots in their names.

Documentation standardization and improvement:

  • Introduced a new shared documentation file, java-env-injection.md, providing a unified and detailed explanation of how Clever Cloud injects environment variables as JVM system properties and how to access them in Java and Scala applications. It also clarifies the handling of variables with dots in their names.
  • Updated Java application documentation (java-gradle.md, java-jar.md, java-maven.md, java-war.md) to include the new shared environment injection content, replacing previous, less detailed instructions. [1] [2] [3] [4]
  • Updated Scala application documentation (_index.md, play-framework-2.md) to use the new shared content and clarify how to access environment variables, ensuring consistency with the Java docs. [1] [2]

🔗 Related Issue (if applicable)


🧪 Type of Change

  • ⚠️ Bug fix
  • 📅 Changelog update
  • 📚 Documentation update
  • ✨ New content/feature
  • 🔧 Technical/maintenance

✅ Quick Checklist

@davlgd davlgd requested a review from Copilot March 19, 2026 16:58
@davlgd davlgd self-assigned this Mar 19, 2026
@github-actions
Copy link
Copy Markdown

:octocat: Preview is deploying...

Please wait while the preview is deploying on Clever Cloud...

ℹ️ Name 🔗 Infos & links
🌱 Deploying commit 012cacb
👁️ Preview Generating preview app...

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardises JVM (Java/Scala) documentation around how Clever Cloud injects environment variables, including support for variable names containing dots by documenting their availability as JVM system properties.

Changes:

  • Added a shared snippet (shared/java-env-injection.md) describing JVM env injection and dotted-variable handling via -D system properties.
  • Updated Java runtime docs (Gradle/Jar/Maven/War) to include the shared snippet instead of duplicating instructions.
  • Updated Scala docs (general + Play 2) to include the same shared snippet for consistency.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
shared/java-env-injection.md New shared JVM env-injection documentation, including dotted-name behaviour via system properties.
content/doc/applications/scala/play-framework-2.md Switches to shared JVM env-injection snippet and tweaks Play-specific access guidance.
content/doc/applications/scala/_index.md Switches Scala docs to shared JVM env-injection snippet.
content/doc/applications/java/java-war.md Includes shared JVM env-injection snippet in WAR docs.
content/doc/applications/java/java-maven.md Includes shared JVM env-injection snippet in Maven docs.
content/doc/applications/java/java-jar.md Replaces inline env-injection section with shared snippet.
content/doc/applications/java/java-gradle.md Replaces inline env-injection section with shared snippet.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +3 to +5
Clever Cloud injects environment variables defined in the Console and by linked add-ons into your application. For JVM-based applications, all environment variables are passed as system properties using `-D` flags, making them accessible through `System.getProperty()`.

To access a standard environment variable such as `MY_VARIABLE`, use `System.getProperty("MY_VARIABLE")` or `System.getenv("MY_VARIABLE")`.

{{% content "env-injection" %}}
{{% content "java-env-injection" %}}

Comment on lines +11 to +15
For example, if you define `my.app.config=production` in the Clever Cloud Console, the JVM receives `-Dmy.app.config=production` at startup. You can then retrieve it with:

```java
String value = System.getProperty("my.app.config"); // returns "production"
```
Comment on lines +3 to +17
Clever Cloud injects environment variables defined in the Console and by linked add-ons into your application. For JVM-based applications, all environment variables are passed as system properties using `-D` flags, making them accessible through `System.getProperty()`.

To access a standard environment variable such as `MY_VARIABLE`, use `System.getProperty("MY_VARIABLE")` or `System.getenv("MY_VARIABLE")`.

#### Variables with dots as JVM system properties

Environment variable names containing a dot (`.`) are handled differently. Since most shells do not support dots in variable names, these variables are passed exclusively as JVM system properties via `-D` flags, and are not set in the shell environment.

For example, if you define `my.app.config=production` in the Clever Cloud Console, the JVM receives `-Dmy.app.config=production` at startup. You can then retrieve it with:

```java
String value = System.getProperty("my.app.config"); // returns "production"
```

This is useful for setting framework-specific properties directly from the Console without modifying configuration files (e.g. Spring Boot properties, Quarkus settings, or any custom `-D` parameter your application expects).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java: document JVM environment variables

2 participants