I am making an interpreted language with java......and am also making an IDE for it. I want to know how to compile java source from my IDE and have it run on a console. I have created a simple console window. But how do i compile java source from my simple IDE and route its output to my console window?
The Interpreted language is interpreted by an interpreter i created and it then creates a java source that needs to be compiled.
You can use the JavaCompiler
interface from the JDK. Read the linked documentation to get an elaborate example of how to use it.
As to running the resulting code, you use the Tool
class.
In general: Check out the javax.tools
package in the JVM.
Assuming you get the syntax right, you would want to compile it using javac
. Now choosing which implementation of the JVM to use is another issue as not everything lines up so "nicely"
精彩评论