Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run a java program from within another java program?

Ok, so basically, I wrote a java program that creates new java classes within the same folder as my current program. So far, that part works absolutely fine since it's just basically creating new text files. What I would like to know though, is if there is a way to run those created classes within the program without terminating the running program that created them. So, basically, I want to write a program that creates, edits, and runs java programs. Is there any method, function, API, that helps to do something like this?

Also, I'm using eclipse to do this.


1 Answers

What I would actually try to do in that case without using external APIs, is to run cmd commands from Java.

In that case you can compile the created Java files and then run the .jar file for example, using terminal commands once more..

For cmd commands through Java you can refer to this link: Run cmd commands through java

like image 159
Jack Avatar answered May 11 '26 19:05

Jack