Jdb Simple Introduction to debugging Scala code

Source: Internet
Author: User

Debugging Java code in the Linux/C + + code is required through GDB. Then you need to use the Jdb tool. The use of jdb on the internet can be found in the corresponding article, but the Scala debugging is relatively small. In fact, the general process of debugging is the same, just need to pay attention to some of the details of the place to be. Here's a quick explanation. Here are the questions about Scala and JDK configuration that are no longer detailed, so let's get to the bottom of it.

First put in the Scala code for debugging Hello.scala

object Hello {    = {        println ("Hello, world!" )        = ten                         = a + b        println (c) = 1 + A; if (d = = one) {          println ("aaaaaaaaa")     }}}

After you have the file, you need to compile it into a byte stream recognized by the virtual machine using the following command. The parameters about Scalac can be viewed through scalac-help.

Scalac-g:vars Hello.scala

After the command executes, you will find two files generated under the directory:hello.class hello$.class

If you run directly with Java, the following error occurs because you do not specify a Scala jar package.

It is also possible to specify CLASSPATH if you want to run it through Java, which is important for JDB to debug Scala later.

Of course, Scala Hello is the right thing to run. Of course you do not manually compile the generated byte stream file directly running Scala Hello.scala is also possible.

Don't know what causes the Hello.scala on Linux to crash through Scala. I suspect that the memory of my machine may be too small due to the use of the VPS only 512m!!!. However, Scala Hello.scala can be run on win.

All of the above are ready for work now is the time to debug.

Please brain the difference in the diagram, because I don't know how to figure it out, it seems that the object in Scala is the result. Have familiar with this words hope that we can come down after a lot of exchanges, here to express thanks ha.

If you are interested, you can go to http://scala-language.1934581.n4.nabble.com/debugging-scala-programs-td1943959.html to see Chris Waterson's comments.

Because it is the first time to write a blog, there is no spectrum, the problem of the place please correct me. The format is ugly, we have a lot to forgive ha! ^_^

Jdb Simple Introduction to debugging Scala code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.