Find compiled project classes

i'm looking for classpath of compiled project/module, because i use library which runs external java methods.
It's simple thing in NetBeans to get complete classloader of the project, but seems as huge problem to get atleast the output directory with compiled classes.
There is no problem to construct my own classloader but i can't find all classes and i'm not speeking about connected libraries, which i also need add to my classloader.

So my question is: How to obtain complete classpath of the project/module.

Thank you for your answer,
Daniel Kec

Comment actions Permalink

So I have found this:

CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
String[] outputRootUrls = extension.getOutputRootUrls(false);

Then i can get all compiled classes.

And with this:

ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
OrderEntry[] orderEntries = ModuleRootManager.getInstance(module).getOrderEntries();

I can get all libraries.

Now i can make my own classloader, it much more complicated than in NetBeans plugin, but i'm getting used to it.
If there is simplier way please correct me.


Comment actions Permalink

Yeah, I think this is the only way. But you don't have to create your own ClassLoader, you can use the UrlClassLoader


Please sign in to leave a comment.