How to call main method of a Scala program from the main method of a java program? -


suppose have scala class , java class in java project , scala class below

class sam {    def main(args: array[string]): unit = {     println("hello")   }  } 

how can call it's main method main method of java program present in same project

typically, main methods static in java, , in object in scala. allows run them command line. code defines class, not object.

i'd suggest changing scala code to:

object sam {   def main(args: array[string]): unit = {     println("hello")   } } 

you can call java main method follows:

class foo  {     public static void main(string[] args) {         sam.main(args);     } } 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -