Created
June 5, 2013 16:28
-
-
Save bancek/5715259 to your computer and use it in GitHub Desktop.
Calling Scala from Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install node-java | |
# npm install java | |
# Create file Foo.scala | |
# case class Foo(bar: String, baz: String) | |
# and compile it | |
# scalac Foo.scala | |
java = require 'java' | |
java.classpath.push '/usr/share/java/scala-library.jar' | |
java.classpath.push '.' | |
# val foo = new Foo("lorem", "ipsum") | |
foo = java.newInstanceSync 'Foo', 'lorem', 'ipsum' | |
# foo.bar | |
foo.barSync() # 'lorem' | |
Foo = java.getStaticFieldValue('Foo$', 'MODULE$') | |
# val foo = Foo("bar", "baz") | |
foo = Foo.applySync('lorem', 'ipsum') | |
# foo.toString() | |
foo.toStringSync() # 'Foo(lorem,ipsum)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment