Skip to content

Commit 52fb1a2

Browse files
committed
Document Java migration tool
1 parent a469722 commit 52fb1a2

1 file changed

Lines changed: 122 additions & 1 deletion

File tree

content/en/docs/refguide/modeling/menus/view-menu/update-assistant.md

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Update Assistant (Beta)"
33
url: /refguide/update-assistant/
44
weight: 70
5-
description: "Describes the Update Assistant (Beta) pane for scanning Java deprecations in Mendix Studio Pro."
5+
description: "Describes the Update Assistant (Beta) pane for scanning Java deprecations in Mendix Studio Pro, and the Java Migration Tool CLI for automatically applying fixes."
66
---
77

88
## Introduction
@@ -64,8 +64,129 @@ This dialog box shows the following information:
6464

6565
The highlighted code helps you locate the deprecated call in the file and update it.
6666

67+
## Java Migration Tool (CLI) {#java-migration-tool}
68+
69+
The **Java Migration Tool** (`jmt`) is a command-line utility that automatically rewrites deprecated Mendix Java API calls.
70+
71+
The tool complements the Update Assistant pane: use the pane to identify deprecations, and the CLI to apply the fixes automatically.
72+
73+
### Installation {#jmt-installation}
74+
75+
Download the tool from Mendix CDN: https://cdn.mendix.com/mendix-java-migration-tool/jmt-1.0.0.jar
76+
77+
### Basic Usage {#jmt-basic-usage}
78+
79+
Run the tool from a Command Prompt. Use the same Java version that Studio Pro uses — you can find the Java installation path in Studio Pro's preferences.
80+
81+
If Java is on your `PATH`, call `java` directly. If not, provide the full path to the `java` executable. Similarly, either run the command from the directory where you saved `jmt-1.0.0.jar`, or specify its full path in the command.
82+
83+
The following example rewrites all Java files in `javasource/` to the target Studio Pro version:
84+
85+
```cmd
86+
"C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot\bin\java" -jar jmt-1.0.0.jar rewrite --to-version 11.11 --studio-pro "C:\Program Files\Mendix\11.11.0" --project-root "C:\Users\YourName\Mendix\MyApp"
87+
```
88+
89+
Replace the paths and version number with the actual values for your installation. For all available commands and options, see [Commands](#jmt-commands) and [Options](#jmt-options).
90+
91+
### Commands {#jmt-commands}
92+
93+
Run the tool with `java -jar jmt-1.0.0.jar <COMMAND> [OPTIONS]`.
94+
95+
| Command | Description |
96+
|---------|-------------|
97+
| `version` | Display the tool version |
98+
| `recipes` | List all available migration recipes |
99+
| `rewrite <PATHS>` | Rewrite Java files at the given paths (files or directories) |
100+
101+
### Options {#jmt-options}
102+
103+
**Global:**
104+
105+
* `-h, --help` – show usage information
106+
107+
**`recipes` command:**
108+
109+
* `-o, --output <FORMAT>` – output format: `text` (default) or `json`
110+
111+
**`rewrite` command:**
112+
113+
* `-t, --to-version <VERSION>`*(required)* target Studio Pro version, for example `11.2.0`
114+
* `-n, --dry-run` – preview changes without writing files
115+
* `-o, --output <FORMAT>` – output format: `text` (default) or `json`
116+
* `-p, --project-root <PATH>` – root of the Mendix project; enables classpath resolution via `javasource/`, `vendorlib/`, and `userlib/`
117+
* `-s, --studio-pro <PATH>` – Studio Pro installation directory; enables Mendix public Java API resolution via the runtime bundles
118+
119+
{{% alert color="warning" %}}
120+
Using `-p` and `-s` is strongly recommended. The tool relies on type binding resolution to apply recipes correctly — for example, it only rewrites `getMember` calls when it can confirm the receiver is an `IMendixObject`. Without these options, type information may be incomplete and recipes may not apply.
121+
122+
For the same reason, the Java code in your project must be error-free as much as possible before running the tool. Missing imports, unresolved types, or variables declared without a fully qualified type name can prevent a recipe from recognizing a valid call site.
123+
{{% /alert %}}
124+
125+
### Examples {#jmt-examples}
126+
127+
```bash
128+
# List available recipes
129+
java -jar jmt-1.0.0.jar recipes
130+
131+
# Apply with full project context for accurate type resolution
132+
java -jar jmt-1.0.0.jar rewrite javasource/ -t 11.2.0 \
133+
-p /path/to/mendix-project \
134+
-s "/path/to/Studio Pro 11.2.0"
135+
136+
# Preview changes without writing (dry run)
137+
java -jar jmt-1.0.0.jar rewrite javasource/ -t 11.2.0 -n
138+
139+
# Apply all applicable recipes to the javasource directory
140+
java -jar jmt-1.0.0.jar rewrite javasource/ -t 11.2.0
141+
142+
# Machine-readable output for CI/CD integration
143+
java -jar jmt-1.0.0.jar rewrite javasource/ -t 11.2.0 -o json
144+
```
145+
146+
### Output Formats {#jmt-output-formats}
147+
148+
**Text** (default) — human-readable summary:
149+
150+
```
151+
[REWRITE] Target version: 11.2.0
152+
Applied recipes:
153+
- Replace IMendixObject.getMember(...) (available from: 10.18)
154+
155+
Changed: javasource/myfirstmodule/actions/MyAction.java
156+
Replace IMendixObject.getMember(...): 2
157+
158+
Files processed: 1
159+
Files changed: 1
160+
Total changes: 2
161+
```
162+
163+
**JSON** — machine-readable, suitable for CI/CD pipelines:
164+
165+
```json
166+
{
167+
"status": "success",
168+
"dryRun": false,
169+
"filesProcessed": 1,
170+
"filesChanged": 1,
171+
"totalChanges": 2,
172+
"files": [
173+
{
174+
"file": "javasource/myfirstmodule/actions/MyAction.java",
175+
"changes": [
176+
{
177+
"recipe": "Replace IMendixObject.getMember(IContext, String) with IMendixObject.getMember(String)",
178+
"count": 2
179+
}
180+
]
181+
}
182+
],
183+
"warnings": []
184+
}
185+
```
186+
67187
## Read More
68188

69189
* [View Menu](/refguide/view-menu/)
70190
* [Errors Pane](/refguide/errors-pane/)
71191
* [Studio Pro Overview](/refguide/studio-pro-overview/)
192+
* [Java Programming](/refguide/java-programming/)

0 commit comments

Comments
 (0)