JavaBin is a library that can be used to download all Amazon Corretto resources from Node.js.
Table of Contents:
- JavaBin
To add this librery to your proyect use this command.
npm i javabin
If you want use the CLI use this command.
npm i -g javabin
To get help of javabin CLI use command javabin -h
.
To use this librery you need to import it frist.
import JavaBin from "javabin";
// or
const JavaBin = require("javabin");
and before get an instance.
const JavaVersion = JavaBin.getInstance(); // Returns Promise<JavaVersion>
The method getInstance
request all data from the oficial github of Amazon Corretto.
If you want list all platforms available you can use this method.
JavaVersion.listPlatforms();
This method returns array all platforms.
Parameters:
- platform: The name of the platform from which you want to obtain its architectures.
Returns:
It method returns an array with all architectures.
JavaVersion.getPlatformArchs("windows");
This method list all platforms with their respective architectures.
Returns:
This method returns an object with each platform in the keys and in each one an array with its possible architectures.
Example:
{
"windows": ["x64", "x86"],
"linux": ["x64", "x86", "arm"],
...
}
JavaVersion.listArchs();
Parameters:
- Platform: The name of platform.
- Arch: The architecture you need.
Returns:
This method return an Platform class instance.
JavaVersion.platform("linux","x64");
This method list all JRE versions that are available.
JavaVersion.platform("linux", "x64").listJreVersions();
This method list all JDK versions that are available.
JavaVersion.platform("linux", "x64").listJdkVersions();
This method list all versions that are available.
Returns:
An object with two keys (JRE, JDK) and in each of its available versions.
Example:
{
"jdk": ["8", "11"...],
"jre": ["8", "11"...]
}
JavaVersion.platform("linux", "x64").listVersions();
To get an JRE version you can use this method.
Parameters:
- Version: The version you want get.
Returns:
This method return an instance of JavaBinariesFormats.
JavaVersion.platform("windows","x64").jre(8);
To get an JDK version you can use this method.
Parameters:
- Version: The version you want get.
Returns:
This method return an instance of JavaBinariesFormats.
JavaVersion.platform("windows","x64").jdk(11);
This class is used to select the format of JavaBinary.
This method is used to list all formats for JavaBinary.
Returns:
Returns array with all formats.
Example:
[
"zip", "msi", "exe"...
]
JavaVersion.platform("win", "x64").jdk(11).listFormats();
This method is used to get an format for JavaVersion.
Returns:
Returns an instance of JavaBinary.
JavaVersion.platform("win", "x64").jdk(11).format("zip");
Method getDownloadUrl:
This method returns the download url for the JavaBinary.
Method download:
This method download return an IncomingDownload.
Parameters:
- downloadPath
optional
: The path where the binary is downloaded. If you not specify an path will be downloaded in the current working directory.
Start
This event is triggered when the download starts.
Callback value:
Object:
{
"total": 100,
"javaBin": {...} // JavaBinary instance
}
Tick
This event is triggered when the download process advances.
Callback value:
Object:
{
"total": 5616424,
"tick": 15852
}
Complete
This event is triggered when the download process ends.
Callback value:
Object:
{
"path":"path_to_java_binary",
"filename": "java_binary_file_name",
"javaBinary": {...} // JavaBinary instance
}