Execute Scala class from inside source code

Good morning all,

Is it possible to have 2 classes example Launcher and MainClass, where in the Launcher Class I would be able to compile and execute the MainClass, given that it is always generated differently please ?

Thanks a lot and good day :slight_smile:

Certainly it is possible, though non-trivial.

There are a few open-source project that have this capability you might want to look at for inspiration how to do it. Ammonite comes to mind first. You might also look at the source code of the β€œscala” command-line utility itself, which also has this capability.

Brian Maso

1 Like