diff --git a/README.md b/README.md
index 48478a5..38b7d2a 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,52 @@
# MyJavaManager
+[](https://www.powershellgallery.com/packages/MyJavaManager)
+[](https://www.powershellgallery.com/packages/MyJavaManager)
[](https://github.com/VouDoo/MyJavaManager/actions/workflows/ci.yml)
-MyJavaManager is a PowerShell module that helps you to manage versions of Java on your Windows system.
+MyJavaManager is a PowerShell module to install, track and switch between Java versions on Windows.
-Available features:
+- **Download Java** from [Adoptium](https://adoptium.net/) (Eclipse Temurin JDK), for the architecture of your system (x64 or ARM64)
+- **Keep track** of your Java versions in an inventory (JSON file), including the ones you installed yourself
+- **Switch between Java versions** in one command: `JAVA_HOME` and `Path` are updated, in the current console too
+- **Remove** a Java version, and optionally its directory, safely
-- Keep in track Java versions in an inventory (i.e. JSON file)
-- Easily switch between java versions (set the `JAVA_HOME` environment variable)
-- Automatically download and install Java package from (previously )
+## Quick start
-## License
+```powershell
+Install-Module -Name MyJavaManager # Install the module from PowerShell Gallery
+Invoke-DownloadJavaPackage -Version 21 # Download Java 21 and add it to the inventory
+Get-JavaEntry # List the Java versions of the inventory
+Switch-JavaVersion # Pick the Java version to use from a menu
+java -version # Ready to use, right away
+```
-MyJavaManager is released under the terms of the MIT license.
+---
-See [LICENSE](LICENSE) for more information or see .
+Table of contents:
+
+- [MyJavaManager](#myjavamanager)
+ - [Quick start](#quick-start)
+ - [Installation](#installation)
+ - [Install from PowerShell Gallery](#install-from-powershell-gallery)
+ - [Get released versions](#get-released-versions)
+ - [Build from Source](#build-from-source)
+ - [Usage](#usage)
+ - [Import the module](#import-the-module)
+ - [Download Java](#download-java)
+ - [Add an existing Java installation](#add-an-existing-java-installation)
+ - [Switch Java version](#switch-java-version)
+ - [Remove a Java version](#remove-a-java-version)
+ - [Commands](#commands)
+ - [Get help](#get-help)
+ - [Contributing](#contributing)
+ - [License](#license)
+ - [Support](#support)
---
## Installation
-To install the PowerShell module, follow one of these methods:
-
-- [Install from PS Gallery](#install-from-ps-gallery)
-- [Get released versions](#get-released-versions)
-- [Build from Source](#build-from-source)
-
The module is **Windows-only** (it relies on the Windows Registry and Windows APIs).
It supports the following PowerShell versions:
@@ -35,10 +56,9 @@ It supports the following PowerShell versions:
Get the latest version of PowerShell from [the official PowerShell repository](https://github.com/PowerShell/PowerShell/releases).
-### Install from PS Gallery
+### Install from PowerShell Gallery
The module is published on PowerShell Gallery.
-
See .
To install it, run:
@@ -47,11 +67,15 @@ To install it, run:
Install-Module -Name MyJavaManager -Repository PSGallery
```
+_On PowerShell 7.4 or later, you can also run `Install-PSResource -Name MyJavaManager`._
+
### Get released versions
Download `MyJavaManager.zip` from [the "Releases" page](https://github.com/VouDoo/MyJavaManager/releases).
+Extract it to your user modules directory:
-Extract it in `C:\Users\\Documents\PowerShell\Modules\`.
+- Windows PowerShell 5.1: `~\Documents\WindowsPowerShell\Modules\`
+- PowerShell 6 and later: `~\Documents\PowerShell\Modules\`
### Build from Source
@@ -64,25 +88,20 @@ Extract it in `C:\Users\\Documents\PowerShell\Modules\`.
2. Build the module
```powershell
- .\build.ps1 build -Bootstrap
- ```
-
- To also run the PSScriptAnalyzer and Pester tests, use the `Test` task:
-
- ```powershell
- .\build.ps1 Test
+ .\build.ps1 Build -Bootstrap
```
3. Remove any old versions of the module
```powershell
- Remove-Item "$HOME\Documents\PowerShell\Modules\MyJavaManager" -Recurse -Force
+ $ModulesDirectory = $env:PSModulePath.Split([System.IO.Path]::PathSeparator)[0]
+ Remove-Item (Join-Path $ModulesDirectory "MyJavaManager") -Recurse -Force -ErrorAction SilentlyContinue
```
4. Install the freshly built module
```powershell
- Copy-Item ".\Out\MyJavaManager" "$HOME\Documents\PowerShell\Modules\" -Recurse
+ Copy-Item ".\Out\MyJavaManager" $ModulesDirectory -Recurse
```
---
@@ -103,9 +122,81 @@ Extract it in `C:\Users\\Documents\PowerShell\Modules\`.
Get-Command -Module MyJavaManager
```
-The fastest way to use the module is to import it from your [PowerShell profile](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles).
+The fastest way to use the module is to import it from your [PowerShell profile](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles) (run `$PROFILE` to get its path).
Then, each time you will open your PowerShell console, the module will be automatically imported.
+Your Java versions are stored in the inventory file `~\MyJavaManager.json`.
+
+### Download Java
+
+To download and install a Java package from Adoptium, use `Invoke-DownloadJavaPackage`.
+
+```powershell
+Invoke-DownloadJavaPackage -Version 21
+```
+
+- Without `-Version`, a menu lets you pick the version (LTS versions are marked, e.g. `21 (LTS)`).
+ In a non-interactive session, the latest LTS (Long-Term Support) version is downloaded.
+- The package is installed in `~\.java_packages`, and an entry is added to the inventory.
+- The package matches the architecture of your system (x64 or ARM64).
+ Adoptium provides Windows ARM64 packages for some Java versions only.
+
+### Add an existing Java installation
+
+To add a Java version that you installed yourself, use `Add-JavaEntry` with the path to its Java home directory.
+
+```powershell
+Add-JavaEntry -Path "C:\Program Files\Java\jdk-17"
+Add-JavaEntry -Path "C:\Program Files\Java\jdk-17" -CustomName MyJava17
+```
+
+The entry is named after the Java version (e.g. `jdk-17.0.1.0`), unless you give a custom name.
+
+### Switch Java version
+
+To use another Java version, use `Switch-JavaVersion`.
+
+```powershell
+Switch-JavaVersion # Pick the Java version from a menu
+Switch-JavaVersion -Name MyJava17 # Use a Java version of the inventory
+Switch-JavaVersion -Path "C:\path\to\java_home_directory" # Use any Java home directory
+```
+
+It sets the `JAVA_HOME` environment variable and adds `%JAVA_HOME%\bin` to the `Path`.
+The current console is updated too, so you can use the new version right away.
+
+The `-Target` parameter defines where the change is saved:
+
+| Target | Description |
+|:---------:| :---------- |
+| `User` | For your user: the current console and new ones. **(Default)** |
+| `Machine` | For all users: the current console and new ones. Requires administrator rights. |
+| `Process` | For the current console only. |
+
+### Remove a Java version
+
+To remove a Java version from the inventory, use `Remove-JavaEntry`.
+
+```powershell
+Remove-JavaEntry -Name MyJava17
+Remove-JavaEntry -Name jdk-11.0.13.0 -RemoveDirectory # Also remove its directory from the disk
+```
+
+With `-RemoveDirectory`, nothing is removed if the directory is not a Java home directory or if it is the current `JAVA_HOME`.
+If other entries use the same directory, only the entry is removed.
+
+### Commands
+
+| Command | Description |
+| :------ | :---------- |
+| `Invoke-DownloadJavaPackage` | Downloads and installs a Java package from Adoptium, and adds it to the inventory. |
+| `Add-JavaEntry` | Adds an existing Java installation to the inventory. |
+| `Get-JavaEntry` | Gets the Java versions of the inventory. |
+| `Switch-JavaVersion` | Switches the Java version in use (`JAVA_HOME` and `Path`). |
+| `Remove-JavaEntry` | Removes a Java version from the inventory, and optionally its directory. |
+
+_Every command that changes something supports `-WhatIf` and `-Confirm`._
+
### Get help
Read help files in [docs/cmdlet-help](docs/cmdlet-help).
@@ -114,6 +205,21 @@ You can also use [the `Get-Help` Cmdlet](https://docs.microsoft.com/en-us/powers
---
+## Contributing
+
+To build the module and run the tests (PSScriptAnalyzer and Pester), run:
+
+```powershell
+.\build.ps1 Test -Bootstrap
+```
+
+Read [docs/development](docs/development) for the docstrings, versioning and publishing guidelines.
+
+## License
+
+MyJavaManager is released under the terms of the MIT license.
+See [LICENSE](LICENSE) or .
+
## Support
If you have any bug reports, log them on [the issue tracker](https://github.com/VouDoo/MyJavaManager/issues).