Issue
I need to get the Eclipse version in 2022-03
format programmatically.
I am trying using Platform.getBundle("org.eclipse.platform").getVersion()
but it is giving the version in 4.23.0.v20220308-0310
format.
Could anyone have a suggestion, please?
Thanks in advance for your time.
Solution
2022-03 is the name of the whole product package, rather than Eclipse Platform which is just one component. 4.23 is the correct version for Platform.
As far as I am aware the 2022-03 name is only present in the about.mappings
file in the "defining bundle" for the product and is just used in the "about" text.
The about.mappings looks something like
# about.mappings
# contains fill-ins for about.properties
# java.io.Properties file (ISO 8859-1 with "\" escapes)
# This file does not need to be translated.
0=I20220817-1800
1=2022-09
2=4.25
You can read this using:
IProduct product = Platform.getProduct();
Bundle bundle = product.getDefiningBundle();
URL location = FileLocator.find(bundle, new Path("about.mappings"));
try (InputStream is = location.openStream())
{
ResourceBundle res = new PropertyResourceBundle(is);
String version = res.getString("1");
}
catch (final IOException ex)
{
...
}
This is based on code in org.eclipse.ui.internal.ProductProperties
Answered By - greg-449
Answer Checked By - Gilberto Lyons (JavaFixing Admin)