Skip to main content

All Questions

Tagged with
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 ...
Aviral Srivastava's user avatar
-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 ...
Mayank Kishore's user avatar
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) } ...
Kevin Meredith's user avatar
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 [...
Maz's user avatar
  • 193
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 &...
ekaqu's user avatar
  • 2,048
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 ...
adelbertc's user avatar
  • 7,300
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:...
Mike Slinn's user avatar
  • 8,255
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 ...
andy legkiy's user avatar
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 ...
Landon Kuhn's user avatar
  • 77.8k
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 ...
eyberg's user avatar
  • 3,230