« Return to Thread: dangerous import java.sql._

Re: dangerous import java.sql._

by Andrew Gaydenko :: Rate this Message:

Reply to Author | View in Thread

java.sql package includes Array interface. I think, with importing you
overwrite scala.Array. Ar a result, you have, in fact,

def main(args: java.sql.Array[String])

instead of

def main(args: scala.Array[String])

As far as main's signature is not expected for legal 'main' method, you get
java.lang.NoSuchMethodError.


On Thursday 09 July 2009 03:55:10 turicum wrote:

> thank you for the prompt reply!
> everything's fine now :)
> Alex
>
> Tony Morris-4 wrote:
> > I shan't spoil it for you, but I shall give ye a hint.
> >
> > When one alters Array for the word scala.Array then all is well.
> >
> > turicum wrote:
> >> Hi everybody!
> >>
> >> Yet another simple and mysterious problem: with the "import" statement,
> >> running the code will generate a "Exception in thread "main"
> >> java.lang.NoSuchMethodError: main". Removing the "import" solves the
> >> problem. What am I missing? Changing the name of the object does not
> >> modify
> >> the outcome. Thanks!
> >>
> >> import java.sql._ // remove this line to get rid of the error msg
> >>
> >> object Sqltest {
> >> def main(args: Array[String]) {
> >>  print("OK")
> >> }
> >> }
> >
> > --
> > Tony Morris
> > http://tmorris.net/

 « Return to Thread: dangerous import java.sql._