Skip to content

Commit 108f7d7

Browse files
committed
Improving experience around gurobi license handling for java app
1 parent c2c419c commit 108f7d7

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

java-gurobi-knapsack/.devcontainer/devcontainer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"jdkDistro": "tem",
1111
"version": "21"
1212
}
13+
},
14+
"workspaceMount": "source=${localWorkspaceFolder}/.,target=/app,type=bind",
15+
"workspaceFolder": "/app",
16+
"containerEnv": {
17+
"GRB_LICENSE_FILE": "/app/gurobi.lic"
1318
}
1419
}

java-gurobi-knapsack/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gurobi.lic

java-gurobi-knapsack/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Example for running a Java `Maven` application on the Nextmv Platform using the
44
Gurobi solver. We solve a knapsack Mixed Integer Programming problem.
55

6+
1. Setup license:
7+
1. **Local**: Add license file `gurobi.lic` to the root of the project.
8+
- If not using VS-Code's dev container, just place the `gurobi.lic` file
9+
in `$HOME/gurobi.lic` (Gurobi's default path for the license).
10+
1. **Platform**: Don't forget to also define the license as a [secret][secret]
11+
in your Nextmv Application as well. This can be easily done via [console].
612
1. Generate a `main.jar`.
713

814
```bash
@@ -35,10 +41,12 @@ the command `Dev Containers: Reopen in Container`.
3541

3642
## Next steps
3743

38-
* Open `src/main/java/com/nextmv/example/Main.java` and modify the model.
39-
* Visit our [docs][docs] and [blog][blog]. Need more assistance?
44+
- Open `src/main/java/com/nextmv/example/Main.java` and modify the model.
45+
- Visit our [docs][docs] and [blog][blog]. Need more assistance?
4046
[Contact][contact] us!
4147

4248
[docs]: https://docs.nextmv.io
49+
[console]: https://cloud.nextmv.io
50+
[secret]: https://www.nextmv.io/docs/using-nextmv/reference/secret-collections
4351
[blog]: https://www.nextmv.io/blog
4452
[contact]: https://www.nextmv.io/contact

java-gurobi-knapsack/java-gurobi-knapsack.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"request": "launch",
1313
"mainClass": "com.nextmv.example.Main",
1414
"projectName": "GurobiJava",
15+
"env": {
16+
"GRB_LICENSE_FILE": "gurobi.lic"
17+
},
1518
"args": ["--input", "input.json", "--output", "output.json"]
1619
}
1720
]

0 commit comments

Comments
 (0)