0

I don't know what's going on or even how to figure it out, but I have a Scala Hello World object, like this.

object TestFoo {
  def main(args: Array[String]): Unit = {
    println("Hello World")
  }
}

The Scala IDE for Eclipse (for Scala 2.9, running Eclipse Indigo) shows no errors and has created a compiled class. When I go to Run > Run As > Scala Application, the terminal console shows no output. However, when I go to the command-line and run scala directly (using the class file Eclipse compiled), I get the correct output:

% scala -cp bin/classes TestFoo
Hello World

Any ideas on what I may have done wrong or can do to correct the problem so that output shows up in Eclipse?

Update: I checked the Console output from Eclipse to see if there was anything usual there after one of the commenters suggesting checking the error log. I see a crash report for Java, with this as the exception:

Java information:
 Exception type: Internal Error (/SourceCache/JavaJDK16/JavaJDK16-424/hotspot/src/share/vm/runtime/fieldDescriptor.cpp, line 85)

#  guarantee(_name_index != 0 && _signature_index != 0) failed: bad constant pool index for fieldDescriptor
zostay
  • 3,985
  • 21
  • 30
  • 1
    does this help? http://scala-ide.org/docs/tutorials/scalac-trunk/index.html – HaloWebMaster Jun 22 '12 at 14:00
  • If you are asking if posting some pages long help document without specifying what about it you think would be helpful helps, then no. What specifically about that document do you think I might be missing? I've read through it and may have overlooked something, but I don't know what it might be. – zostay Jun 22 '12 at 14:30
  • 1
    Have you tried Scala > Run Setup Diagnostics? Failing that, you could try opening a new workspace and see if you still get the same problem – Luigi Plinge Jun 22 '12 at 15:00
  • Is there anything in the Eclipse Error Log? – Matthew Farwell Jun 22 '12 at 15:59
  • Nothing in setup diagnostics, but a new workspace resolved it. That gives me something to work with in trying to find the problem at least. Thanks. – zostay Jun 22 '12 at 16:05
  • No, nothing on the console output and nothing in the Eclipse Error Log view. – zostay Jun 22 '12 at 16:06
  • Oh, wait a minute. I checked the console again, and I have a Java crash report. Editing the post to put it in. – zostay Jun 22 '12 at 16:08
  • Tried `./eclipse -clean` to clean up the workspace. No joy. Keep looking... – zostay Jun 23 '12 at 02:50
  • What Eclipse Indigo version are you using? (Classic?) What JDK are you using? (Oracle?) Also, can you create a Java project, and run a Java main? If yes, mabe try downloading a fresh Eclipse and install the Scala IDE only to check if that works? – Mirco Dotta Jun 23 '12 at 09:21
  • After browsing the web for the same error, I'm more and more convinced that you have a corrupted Eclipse installation. Maybe, uninstall the Scala IDE and try to run the following from the terminal: ``eclipse -application org.eclipse.equinox.p2.garbagecollector.application -profile ``, where ```` comes from config.ini (e.g., epp.package.jee) and ``eclipse`` is the Eclipse executable. Then install again the Scala IDE and see if it works. (Or, the easier way, download a new Eclipse and install the Scala IDE again, hopefully it will work.) – Mirco Dotta Jun 23 '12 at 10:39

1 Answers1

1

Okay, so after further investigation it appears that everything was working correctly so long as I use a Scala project for doing the work. It might also work with a typical Java project running a mix of Scala and Java.

In this case, I was trying to get a test script running in an Android project and it cannot find the terminal there at all and has the exception reported. That's what I was doing wrong.

If you are having trouble running a console app from within an Android project or some other non-Scala project, that's probably the problem. Use a Scala project for such things.

zostay
  • 3,985
  • 21
  • 30
  • Ouch, you were trying to execute "Run As Scala Application" on a Java project? And if you want a mixed Java/Scala project, make sure to add the **Scala Nature** to your project. The Eclipse Java compiler knows nothing about Scala ;-) – Mirco Dotta Jun 24 '12 at 07:53