I am trying javap -p classname on scala class but getting error in REPL

631 Views Asked by At
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 Department
       ^
<console>:12: error: not found: value p
       javap -p Department
              ^
1

There are 1 best solutions below

2
On

You cannot invoke javap program as if you are in the normal shell, because the Scala REPL is not a shell.

You can use the built-in command :javap though:

scala> class Department( val departmentId: Int, val departmentName: String)
defined class Department

scala> :javap -p Department
Compiled from "<console>"
public class $line4.$read$$iw$$iw$Department {
  private final int departmentId;
  private final java.lang.String departmentName;
  public int departmentId();
  public java.lang.String departmentName();
  public $line4.$read$$iw$$iw$Department(int, java.lang.String);
}

From the REPL :help:

:javap <path|class> disassemble a file or class name