bingodopa.blogg.se

Compiling java code in linux
Compiling java code in linux







compiling java code in linux

$ scala -classpath classes:lib/DateUtils.jar Īs you can imagine, this process gets more and more difficult as you add new classes and libraries, and it’s strongly recommended that you use a tool like SBT, Maven, or Ant to manage your application’s build process. Once the files have been compiled in this manner, you can run the application like this: classes/com/alvinalexander/pizza/Topping.class classes/com/alvinalexander/pizza/Topping$.class classes/com/alvinalexander/pizza/Pizza.class classes/com/alvinalexander/pizza/Main.class classes/com/alvinalexander/pizza/Main$delayedInit$body.class classes/com/alvinalexander/pizza/Main$.class $ scalac -classpath lib/DateUtils.jar -d classes " src/com/alvinalexander/pizza/*Īssuming Main.scala is an object that extends App, Pizza.scala is a regular class file, and Topping.scala is a case class, your classes directory will contain these files after your scalac command: Given this configuration, to compile your source code files to the classes directory, use the following command: The Main.scala, Pizza.scala, and Topping.scala files will also have package declarations corresponding to the directories they are located in, i.e.: src/com/alvinalexander/pizza/Topping.scala src/com/alvinalexander/pizza/Pizza.scala src/com/alvinalexander/pizza/Main.scala In this case, your files and directories will look like this:

compiling java code in linux

In a more complicated example, you may have your source code in subdirectories under a src folder, one or more JAR files in a lib directory, and you want to compile your output class files to a classes folder. Override def toString = toppings.toStringĪssuming that the Topping class is compiled to a file named Topping.class in a subdirectory named classes, compile Pizza.scala like this: For instance, if you have a class named Pizza in a file named Pizza.scala, it may depend on a Topping class: As the Kodi codebase is constantly changing, instructions for building Kodi for each platform are not contained in the wiki, instead they are contained on Github.

Compiling java code in linux software#

For example, given a Scala source code file named Hello.scala:Ĭompile it from the command line with scalac:Ĭompiling and executing classes is basically the same as Java, including concepts like the classpath. Kodi is open source (GPL) software and the source code is available for anyone to modify and/or compile under the rules of the GPL. SolutionĬompile programs with scalac, and run them with scala. Though you normally use the Simple Build Tool (SBT) to build Scala applications, you may want to use more basic tools to compile and run small test programs, in the same way you might use javac and java with small Java applications. This is Recipe 14.5, “How to compile Scala code with scalac and run it with scala.” Problem This is an excerpt from the Scala Cookbook.

  • show more info on classes/objects in repl.








  • Compiling java code in linux