This page is no longer maintained — Please continue to the home page at www.scala-lang.org

scala “error: io error while decoding” “with utf-8”

6 replies
deepblue_other
Joined: 2009-12-18,
User offline. Last seen 42 years 45 weeks ago.

hello everyone
Im having a problem running a compiled .class file with scala
this thing keeps coming up
I checked that all my source files are utf8 encoded, and Im using '-encoding
UTF8' flag with both scalac and scala command line tools
any ideas?
ps Im compiling and running on Ubuntu, Scala 2.7.7
Im editing in using jEdit from a windows machine, and I checked to make sure
all my .scala files are UTF8 encoded. scalac compiles all the files fine,
with a "-encoding UTF8" flag

thank you

bmaso
Joined: 2009-10-04,
User offline. Last seen 2 years 40 weeks ago.
Re: scala “error: io error while deco ding” “with utf-8”
What keeps "coming up"? You left essential implicit evidence out.

Best regards,
Brian Maso
(949) 395-8551
brian@blumenfeld-maso.com
twitter: @bmaso
skype: brian.maso
LinkedIn: http://www.linkedin.com/in/brianmaso

On Fri, Dec 18, 2009 at 1:15 PM, deepblue_other <cktgatb@gmail.com> wrote:

hello everyone
Im having a problem running a compiled .class file with scala
this thing keeps coming up
I checked that all my source files are utf8 encoded, and Im using '-encoding
UTF8' flag with both scalac and scala command line tools
any ideas?
ps Im compiling and running on Ubuntu, Scala 2.7.7
Im editing in using jEdit from a windows machine, and I checked to make sure
all my .scala files are UTF8 encoded. scalac compiles all the files fine,
with a "-encoding UTF8" flag

thank you
--
View this message in context: http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2%80%9D-%E2%80%9Cwith-utf-8%E2%80%9D-tp26849825p26849825.html
Sent from the Scala - User mailing list archive at Nabble.com.


deepblue_other
Joined: 2009-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: scala “error: io error while decoding” “with utf-8”

the error thats in the title of the message, sorry for not being clear
“error: io error while decoding FileName.class with utf-8
please try specifying another one using the -encoding option”

this is returned by "scala" runner, not the scalac compiler... the .scala
files compile fine, its when I try to run the produced .class files that I
get the errors

Brian Maso wrote:
>
> What keeps "coming up"? You left essential implicit evidence out.
>
> Best regards,
> Brian Maso
> (949) 395-8551
> brian@blumenfeld-maso.com
> twitter: @bmaso
> skype: brian.maso
> LinkedIn: http://www.linkedin.com/in/brianmaso
>
> On Fri, Dec 18, 2009 at 1:15 PM, deepblue_other wrote:
>
>>
>> hello everyone
>> Im having a problem running a compiled .class file with scala
>> this thing keeps coming up
>> I checked that all my source files are utf8 encoded, and Im using
>> '-encoding
>> UTF8' flag with both scalac and scala command line tools
>> any ideas?
>> ps Im compiling and running on Ubuntu, Scala 2.7.7
>> Im editing in using jEdit from a windows machine, and I checked to make
>> sure
>> all my .scala files are UTF8 encoded. scalac compiles all the files fine,
>> with a "-encoding UTF8" flag
>>
>> thank you
>> --
>> View this message in context:
>> http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2...
>> Sent from the Scala - User mailing list archive at Nabble.com.
>>
>>
>
>

Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: scala “error: io error while deco ding” “with utf-8”

Once you have compiled a .scala file containing an object with a main
method, you must use java to run them, including the scala library on
the classpath.

~: cat > Foo.scala
object Foo { def main(args: Array[String]) = println("Hello, World!")}
~: scalac Foo.scala
~: ls Foo.class
Foo.class
~: java -classpath ~/usr/scala-2.8.0.latest/lib/scala-library.jar:. Foo
Hello, World!

Alternatively, you can use `scala` to directly run a snippet of code.

~: cat > Bar.scala
println("Hello, World!")
~: scala Bar.scala
Hello, World!

The error is caused by the scala script runner trying to decode the
binary contents of a .class file as UTF-8 text.

-jason

On Fri, Dec 18, 2009 at 11:08 PM, deepblue_other wrote:
>
> the error thats in the title of the message, sorry for not being clear
> “error: io error while decoding FileName.class with utf-8
> please try specifying another one using the -encoding option”
>
> this is returned by "scala" runner, not the scalac compiler... the .scala
> files compile fine, its when I try to run the produced .class files that I
> get the errors
>
> Brian Maso wrote:
>>
>> What keeps "coming up"? You left essential implicit evidence out.
>>
>> Best regards,
>> Brian Maso
>> (949) 395-8551
>> brian@blumenfeld-maso.com
>> twitter: @bmaso
>> skype: brian.maso
>> LinkedIn: http://www.linkedin.com/in/brianmaso
>>
>> On Fri, Dec 18, 2009 at 1:15 PM, deepblue_other wrote:
>>
>>>
>>> hello everyone
>>> Im having a problem running a compiled .class file with scala
>>> this thing keeps coming up
>>> I checked that all my source files are utf8 encoded, and Im using
>>> '-encoding
>>> UTF8' flag with both scalac and scala command line tools
>>> any ideas?
>>> ps Im compiling and running on Ubuntu, Scala 2.7.7
>>> Im editing in using jEdit from a windows machine, and I checked to make
>>> sure
>>> all my .scala files are UTF8 encoded. scalac compiles all the files fine,
>>> with a "-encoding UTF8" flag
>>>
>>> thank you
>>> --
>>> View this message in context:
>>> http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2...
>>> Sent from the Scala - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2...
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: scala “error: io error while decoding” “with utf-8”
I never thought he might be doing that... However, I must point out that you are incorrect. You can use "scala" to run compiled code, but you do not pass the name of the _file_ to it. Instead, you pass the name of the object containing "main". In the code below:   scala Foo

On Fri, Dec 18, 2009 at 8:24 PM, Jason Zaugg <jzaugg@gmail.com> wrote:
Once you have compiled a .scala file containing an object with a main
method, you must use java to run them, including the scala library on
the classpath.

 ~: cat > Foo.scala
object Foo { def main(args: Array[String]) = println("Hello, World!")}
 ~: scalac Foo.scala
 ~: ls Foo.class
Foo.class
 ~: java -classpath ~/usr/scala-2.8.0.latest/lib/scala-library.jar:. Foo
Hello, World!

Alternatively, you can use `scala` to directly run a snippet of code.

 ~: cat > Bar.scala
println("Hello, World!")
 ~: scala Bar.scala
Hello, World!

The error is caused by the scala script runner trying to decode the
binary contents of a .class file as UTF-8 text.

-jason

On Fri, Dec 18, 2009 at 11:08 PM, deepblue_other <cktgatb@gmail.com> wrote:
>
> the error thats in the title of the message, sorry for not being clear
> “error: io error while decoding FileName.class with utf-8
> please try specifying another one using the -encoding option”
>
> this is returned by "scala" runner, not the scalac compiler... the .scala
> files compile fine, its when I try to run the produced .class files that I
> get the errors
>
> Brian Maso wrote:
>>
>> What keeps "coming up"? You left essential implicit evidence out.
>>
>> Best regards,
>> Brian Maso
>> (949) 395-8551
>> brian@blumenfeld-maso.com
>> twitter: @bmaso
>> skype: brian.maso
>> LinkedIn: http://www.linkedin.com/in/brianmaso
>>
>> On Fri, Dec 18, 2009 at 1:15 PM, deepblue_other <cktgatb@gmail.com> wrote:
>>
>>>
>>> hello everyone
>>> Im having a problem running a compiled .class file with scala
>>> this thing keeps coming up
>>> I checked that all my source files are utf8 encoded, and Im using
>>> '-encoding
>>> UTF8' flag with both scalac and scala command line tools
>>> any ideas?
>>> ps Im compiling and running on Ubuntu, Scala 2.7.7
>>> Im editing in using jEdit from a windows machine, and I checked to make
>>> sure
>>> all my .scala files are UTF8 encoded. scalac compiles all the files fine,
>>> with a "-encoding UTF8" flag
>>>
>>> thank you
>>> --
>>> View this message in context:
>>> http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2%80%9D-%E2%80%9Cwith-utf-8%E2%80%9D-tp26849825p26849825.html
>>> Sent from the Scala - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/scala-%E2%80%9Cerror%3A-io-error-while-decoding%E2%80%9D-%E2%80%9Cwith-utf-8%E2%80%9D-tp26849825p26850365.html
> Sent from the Scala - User mailing list archive at Nabble.com.
>
>



--
Daniel C. Sobral

I travel to the future all the time.
Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: scala “error: io error while decoding” “with utf-8”

Oh, that's much simpler than using java directly!

~: scala Foo
Hello, World!
~: scala Foo.class
error: IO error while decoding /Users/jason/Foo.class with UTF-8
Please try specifying another one using the -encoding option one error found

On Fri, Dec 18, 2009 at 11:59 PM, Daniel Sobral wrote:
> I never thought he might be doing that... However, I must point out that you
> are incorrect. You can use "scala" to run compiled code, but you do not pass
> the name of the _file_ to it. Instead, you pass the name of the object
> containing "main". In the code below:
>
> scala Foo

deepblue_other
Joined: 2009-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: scala “error: io error while decoding” “with utf-8”

thanks guys
the problem, as you indicated, was that I was including the .class extension
when running

_retronym wrote:
>
> Oh, that's much simpler than using java directly!
>
> ~: scala Foo
> Hello, World!
> ~: scala Foo.class
> error: IO error while decoding /Users/jason/Foo.class with UTF-8
> Please try specifying another one using the -encoding option one error
> found
>
> On Fri, Dec 18, 2009 at 11:59 PM, Daniel Sobral
> wrote:
>> I never thought he might be doing that... However, I must point out that
>> you
>> are incorrect. You can use "scala" to run compiled code, but you do not
>> pass
>> the name of the _file_ to it. Instead, you pass the name of the object
>> containing "main". In the code below:
>>
>> scala Foo
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland