1

I am working on delivering a new feature for a Java based enterprise application. A lot of workareas/projects will be uptaking my feature. But I am not willing that we import the jar containing the new feature and include it in all individual classpaths for all projects. I have been wondering wether it would be possible at all to instantiate a java object to use there methods, but without importing the containing jar in the project's classpath. Other than the generic methods to instantiate a java object: new, clone(), ApplicationContext.getBean/ autowiring in spring framework to mention a few, but these all generally expect the containing jar to be present in the context. Is there any possibility across any java based framework which could facilitate this programming routine?

One working example is from Oracle ADF, where we can make use of ApplicationModule in the data model. And with the help of the applicationModule instance, we can access any view object (read: java object) across any project in the workspace without importing the containing jar in classpath.

Akash Mishra
  • 682
  • 1
  • 5
  • 13
  • You can load jars at runtime. See this post: http://stackoverflow.com/a/60775/3579095 – Lars Aug 04 '16 at 18:44
  • A class is not instantiated in a project but in a running JVM that is able to locate classes for which it uses class loaders. So such a class must be accessible somehow. Or you can switch to remote calls or similar. – Seelenvirtuose Aug 04 '16 at 18:44
  • @Lars I had a chance to look at the post earlier.. I saw quite a few potential solutions to problem, but the issue at hand is still an open query. The best and most suggested solutions mentioned in the post require/expect to consume the Jar name (as in case of ClassLoaders etc) or have the dependency mentioned beforehand (as in the case of Java Module System). However I might not have the jar file/dependency of the Java class specified in my target (new project) everytime. – Akash Mishra Aug 05 '16 at 07:41

0 Answers0