0

How to run external programs in pure Kotlin?

From a program written in Kotlin for Windows, I want to run external programs. I want to do it I want to do it in pure Kotlin (not Java). Please provide sample code.

For example: how to start and open Notepad with .txt file, MyProgram.exe. (in Windows it's the WinExec() function) What to read about it, maybe a few links. :)

I'm a beginner. I've read the kotlin documentation and couldn't find anything.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Does this answer your question? [How to invoke external command from within Kotlin code?](https://stackoverflow.com/questions/35421699/how-to-invoke-external-command-from-within-kotlin-code) – chris Feb 18 '23 at 11:34
  • What do you mean by ‘pure Kotlin (not Java)’? Are you writing cross-platform Kotlin (that could be compiled for any of Kotlin/Native, Kotlin/JS, or Kotlin/JVM), or for Kotlin/Native, or Kotlin/JVM? I doubt this is possible in the cross-platform case (as I believe things are still quite limited in many ways); in Kotlin/Native I think [you can use `platform.posix`](/a/64311102/10134209); and in Kotlin/JVM there's no reason not to use `java.lang.Runtime` or `java.lang.ProcessBuilder`. – gidds Feb 18 '23 at 12:50
  • Nie mam nawet projektu. – Sebastian Grześlak Feb 18 '23 at 17:56

0 Answers0