All Questions
10
questions
0
votes
0
answers
55
views
How to write scala jar executable by Java to fetch hostname of the machine?
I want to perform this activity in Scala and execute it with Java:
hostname -i
The scala code for this is:
import java.net._
object HostName {
def main(args: Array[String]){
val ...
-2
votes
1
answer
633
views
I am trying javap -p classname on scala class but getting error in REPL
scala> class Department( val departmentId: Int, val departmentName: String)
defined class Department
scala> javap -p Department
<console>:12: error: not found: value javap
javap -p ...
0
votes
1
answer
82
views
Understanding Type in Compiled Scala File
Given:
$cat build.sbt
scalaVersion := "2.12.1"
$cat src/main/scala/net/X.scala
package net
trait Foo
object X {
val a: Int with Foo = 42.asInstanceOf[Int with Foo]
println(a + a)
}
...
0
votes
1
answer
558
views
No javap tool not found in Scala REPL
I am using Scala 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_79) on Windows 10.
I did following in REPL
scala> class Book (val title:String)
defined class Book
scala> :javap
:javap [...
2
votes
1
answer
930
views
Unable to use scala's repl :javap to look at trait companion object
I am using the :javap command in the scala repl and was trying to look at the traits companion object, but I couldn't seem to find out how. Here is what I do from command line.
$ cat > Foo.scala &...
4
votes
1
answer
205
views
javap difference when compiling with/without assertion
Scala for the Impatient Chapter 15 Exercise 10: Add assert(n >= 0 to a factorial method. Compile with assertions enabled and verify that factorial(-1) throws an exception. Compile without ...
33
votes
2
answers
5k
views
How to learn about using scala.None from Java using javap?
In a previous question, Accessing scala.None from Java, it seems that people had used javap to figure out how to access scala.None from Java. I would like to know how they did that. FYI, the answer is:...
18
votes
2
answers
7k
views
Add tools.jar in the classpath of sbt project
The ':javap' command in the scala 2.9.1 console need the tools.jar (from JDK6) in the 'classpath'. From cmd-line it could be done with '-cp' argument or CLASSPATH environment variable.
How to do the ...
5
votes
2
answers
686
views
Scala: using reflection to discover your inner objects (and desires)?
Is there a way to at runtime discover objects declared inside an outer object? The Java Class methods getClasses and getDeclaredClasses both return empty arrays.
object Parent {
object Child1
...
13
votes
1
answer
2k
views
How do I alias the scala setter method 'myvar_$eq(myval)' to something more pleasing when in java?
I've been converting some code from java to scala lately trying to teach myself the language.
Suppose we have this scala class:
class Person() {
var name:String = "joebob"
}
Now I want to access ...