How to utilize the Java JDK-provided file tools.jar in a plugin?

Hi there,

I am developing a plugin for an Atlassian product, and I would like to use the tools.jar file provided by Java JDKs in my plugin, but I can't grok how.

The file in question is usually found in the lib/ folder directly beneath the JDK home directory as described below (in a simplified form):

The relative path of the tools.jar file:

jdk1.8.0/lib/tools.jar

The relative path of the JRE:

jdk1.8.0/jre

As described on the Managing dependencies page of the Atlassian SDK Developer documentation, when developing a plugin, we have to take classloader isolation and runtime dependencies into consideration when reasoning about what classes are and can be loaded.

If possible, I do not wish to bundle tools.jar with my plugin, however, as I foresee that this could lead to several problems with incompatibilities between the SDK used for the Atlassian server application process and the tools.jar provided by the plugin. I would rather use the file included on the server with the JDK.

The question is then: if I cannot go down the route of bundling the tools.jar file with my plugin, how do I bend/extend the OSGi system to also include tools.jar as a container-provided package, and not a plugin-provided one?

(I should add that I have verified that I can access and use the classes within the tools.jar file from ScriptRunner using the classic methods of adding jar files to the classpath, so my code works as long as the classes can be loaded).

Thanks in advance.

Best,
Thomas

1 answer

0 vote
Alexey Matveev Community Champion Dec 27, 2017

Hello,

You would need to convert the jar to OSGI bundle first. Then you can attach it to your plugin. Kindly read more here

https://helpx.adobe.com/experience-manager/kb/ConvertAJarIntoOsgiBundle.html

https://developer.atlassian.com/server/framework/atlassian-sdk/bundling-extra-dependencies-in-an-obr/

Hi Alexey,

Thank you very much for your reply.

I would, however, like to avoid bundling it with my plugin, and instead use the one found in the JDK on the server.

Best,
Thomas

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

296 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you