File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Implementing a Java interface at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Implementing a Java interface at runtime" Watch "Implementing a Java interface at runtime" New topic
Author

Implementing a Java interface at runtime

Aiden Nibali
Greenhorn

Joined: May 26, 2009
Posts: 5
Hi,
I was just wondering whether it is possible to evaluate Java code at runtime in order to implement an interface. I've tried using the JavaScriptEngine (with javax.script stuff), but for some reason the created class can't be cast into the original interface. Somehow two incompatible interfaces which appear identical are created. Are there any alternative solutions out there?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Check out java.lang.reflect.Proxy.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Aiden Nibali
Greenhorn

Joined: May 26, 2009
Posts: 5
Thanks, that looks like what I want. You wouldn't believe how difficult it was to find help using Google!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Implementing a Java interface at runtime