Skip to content

Instantly share code, notes, and snippets.

@89465127
Created April 18, 2013 23:42
Show Gist options
  • Save 89465127/5417064 to your computer and use it in GitHub Desktop.
Save 89465127/5417064 to your computer and use it in GitHub Desktop.
How to compile and run HelloWorld programs in java and scala through the command line terminal, with jar dependencies.
#Compile HelloWorld, with jars in this directory
javac -cp ".:*" HelloWorld.java
scalac -cp ".:*" HelloWorld.scala
#Run
java -cp ".:*" HelloWorld
scala -cp ".:*" HelloWorld
# HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java World!"); // Display the string.
}
}
# HelloWorld.scala
object HelloWorld {
def main(args: Array[String]) {
println("Hello, Scala World!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment