I want to be able to call javac <class file name>
, and then automatically run java on the compiled .class
file.
I thought initially to use a x86 disassembler to hack it (javac.exe) but bumped that idea; I then found the open source code for JDK, and concluded that maybe a batch file would be easier. How can I do this?
4
It would probably be easier to use a build tool, like Ant. You could have a target to compile, a target to run your tests, a target to run, and so forth. You can set up different dependencies between them (for example, always make test clean your build files and compile before running).
Alternatively, a shell script would be the next best bet. However, that would be far less portable than something like Ant.
Do you want to run this as a process from within another Java process or from the Shell ?
If its from within a Java process,take a look at the Processbuilder API
1