Can we use scala to debug Java programs

I participated in a survey of a senior Java candidate, and he mentioned that they make extensive use of the scala command line to debug Java programs. He said that you can even call a Java function directly from the scala command line.

I never used scala, so I could not check his comments. This may be possible because both of them work on the JVM itself.

A quick google search gives no indication of this.

Is it really possible to debug Java functions from scala. Can someone give me pointers to the same.

Thanks in advance.

+4
source share
1 answer

Yes, you can, although you will have to use the scala syntax:

:: ~ » scala                                                                               
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> val x = new java.io.File("/tmp/foo")
x: java.io.File = /tmp/foo

scala> x.length
res0: Long = 24777

scala REPL, scala, sbt (scala analog to maven), :

sbt
console
.... // using java code, just like any other jvm code

vanila REPL , :

scala -classpath ...

, @Boris , IDE ( Eclipse, IDEA ) - ( ):

enter image description here

+8

Source: https://habr.com/ru/post/1541071/


All Articles