Ganesh Rao B
Ganesh Rao B

Reputation: 501

NLS initializing Messaging

I am using the NLS.initializeMessages(BUNDLE_NAME, XYZ.class) to load the constants.

When 'BUNDLE_NAME' and 'XYZ.class' are present in the same project it works, but when it's in a different project it is not working.

Can we use the above API when we have 'BUNDLE_NAME' and 'XYZ.class' in different project?

Upvotes: 0

Views: 313

Answers (1)

greg-449
greg-449

Reputation: 111216

If the class is in another plugin which is not in your plugin's dependency list then you need to know the id of the plugin to load the class.

You would get the class using:

Bundle bundle = Platform.getBundle("the plugin id");

Class<?> theClass = bundle.loadClass("the class name");

You can then use NLS.initializeMessages using the class, but the BUNDLE_NAME you specify must be loadable by the class loader for theClass - which means it must be in the same plugin or one of that plugin's dependencies, it can't be in your plugin.

Upvotes: 2

Related Questions