This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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: 19697
    
  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!
 
GeeCON Prague 2014
 
subject: Implementing a Java interface at runtime