dpaksp
dpaksp

Reputation: 737

From one java file compile other java file

here is my case ...i have one xxxxxx.java file when compile and run the file i get output as yyyyyy.java file .....but i need yyyyyy.class file i.e is from xxxxxx.java file should automatically compile it output file and get yyyyyy.class...can this be done in java

thanks

Upvotes: 1

Views: 132

Answers (2)

unbeli
unbeli

Reputation: 30248

Use the interface from the tools package. There are enough examples on the web, one is here: http://www.java2s.com/Code/Java/JDK-6/CompilingfromMemory.htm

Upvotes: 1

Michael Borgwardt
Michael Borgwardt

Reputation: 346476

Since Java 6, this can be done via the JavaCompiler API in javax.tools.

Upvotes: 1

Related Questions