javarapidminer

How to use a custom object from a not accessible .jar


I have an .jar file that is used by a program, I want to write an extension for. One of my new methods requires a custom object from that jar. If I import that custom class, I get an error because in eclipse the imported class and the required class seem to be different even if they have the same name.

Is it possible to use an object from a different project?

I can't import the jar because it's an extension. So it can be downloaded and used. I just want to extend this extension but I don't want to change the extension itself. I've tried to cast the object but I get an error that it can't be casted.


Solution

  • This sounds like a classpath problem. Chances are that the original extension is in the classpath and again as part of your extension extension. For a class to be considered the same by the JVM, it must be in the same package, have the same name and be loaded by the same classloader. So a class loaded from your extension extension .jar is definitely considered different from any class of the same name loaded from the original extension .jar by another classloader, even if they are in fact bit-by-bit identical.