The Wayback Machine - https://web.archive.org/web/20111102023823/http://www.devx.com/Java/Article/7866
advertisement
Not sure if you have an account?
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Sidebar: Scripting vs. Programming
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Build a Reflection-based Interpreter in Java

Java's support of reflection enables you to create an interpreter that executes commands interactively. This article demonstrates how to build a reflection-based system that allows simple scripting of Java programs without having to install a special-purpose scripting language. It also provides a downloadable sample program. 


advertisement
cripting languages exist because some programming tasks are both simple and important, and carrying them out with a language that doesn't tax the mind as much as a system programming language sometimes will is beneficial. (See Sidebar: Scripting vs. Programming for a full explanation of the differences between scripting languages and programming languages.) Although Java is most decidedly a programming language (it is typed, highly structured, and compiled), don't you sometimes wish you could do scripting in Java, or something close to Java?

Thanks to the Reflection API, you can. Using the Reflection API, you can run methods dynamically. Java's support of reflection enables you to create an interpreter that executes commands interactively. This article describes a system you can use to build an interpreter into your application. It demonstrates how to build a reflection-based system that allows simple scripting of Java programs without having to install a special-purpose scripting language. It also provides a downloadable sample program. This solution can allow you to create simple control scripts for your Java programs.


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement
Advertising Info  |   Permissions  |   Help  |   Site Map  |   Network Map  |   About

Internet.com
The Network for Technology Professionals

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

207.241.237.237