All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.util.exec.kt Maven / Gradle / Ivy

package com.jtransc.util

import com.jtransc.text.captureStdout

object ClassUtils {
	@JvmStatic fun  callMain(clazz: Class, vararg args: String): String {
		com.jtransc.log.log("Executing: " + clazz.name + ".main()")
		val result = captureStdout {
			val m = clazz.getDeclaredMethod("main", Array::class.java) ?: throw RuntimeException("Class $clazz doesn't have a static method 'main'")
			m.invoke(null, args as Any)
		}
		com.jtransc.log.log("Result: " + result)
		return result
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy