This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 19651
    
  18

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
 
Similar Threads
Strings in java.
static members and inheritance
Doubt regarding invocation of JAX-WS through java client code
== operator returns true for Strings
Heap & Pool