Posted by otaviojava
on January 19, 2014 at 7:14 PM PST
In this article you will learn how compile Java sources on runtime using the JSR 199 API.
The Java is a platform which grown up quickly, for many rations such it can write once time and run anywhere, it runs languages on JVM. There is a myth that Java cannot compile its sources on run time, but it's truth?
Have a dynamic language is important to make some projects, for example, calculate taxes to different cities, so the source should be on the database and each city it puts the specific formula.
To show this functionality we will use a sample to solved the problem above, do change of formula on run time, to be easy and get focus on demonstration, we will use the four simple operations (add, multiply, subtract and divide) and to simulate the database, will have the txt file with Java's source inside. How cannot reference a class that was not created yet, we will make a interface to all classes on our