Eclipse and Scala-IDE source files encoding bug?
Asked Answered
G

2

6

I am working on a simple project in Eclipse in Scala-IDE. The project makes use of someone else's library (which comes in *.java source files, not in a .jar). The library source files contain numerous comments in Japaneese. I cannot compile the Scala project since for every such file I get an error like this one:

IO error while decoding D:\path\FileName.java with windows-1252 Please try specifying another one using the -encoding option

Seems like I did not have this problem when the project was in Java. Now I am migrating to Scala and that is what I am getting.. I do not want to delete all these comments, is there any way to make the compiler handle them? I have tried all kinds of encoding fixes starting from Preferences->Resources->Text file encoding and ending with eclipse.ini file encoding parameters...

Galiot answered 7/2, 2012 at 14:52 Comment(0)
G
10

I have resolved the issue. The Scala compiler has a different set of options that likely does not subdue to the global Eclipse options. So by going to Preferences->Scala->Compiler and adding -Dfile.encoding=UTF-8 to the Additional command line parameters field I have fixed the error.

Galiot answered 7/2, 2012 at 15:1 Comment(6)
This is a bug (or at least a feature request). You should report this on assembla.com/spaces/scala-ide/tickets.Assemble
I cannot add a ticket there.. even if I login with my google account, the "New Ticket" button does not appear.Galiot
There seems to be a problem with the google login. Try registering under a different usernameAssemble
@MatthewFarwell: Nope, I have tried that and I have been waiting while they fix the problem, but still I cannot see the "New Ticket" button. Strange, really..)Galiot
I'm having the same problem, but adding -Dfile.encoding=UTF-8 didn't fix the problem.Stegosaur
@FilipeRoberto are you sure, you're adding the param to the compiler command line? Sorry I have long moved to Clojure and unaware of the current workings of Scala IDE, so I cannot give you any exact advice :) But the general point is that the Scala compiler should invoke Java compiler with that parameter. You may have to look for the exact way of implementing it today... You can also try setting global Java compiler parameters, hoping they'll be effective. Also please consider complementing the accepted reply with your solution if you find it :)Galiot
A
11

I had a similar issue after I switched from linux to macosx

Eclipse default text file encoding was set to US-ASCII, to fix this:

(Eclipse Juno)

  1. Open the preferences
  2. General - Workspace
  3. Switch "text file encoding" to "UTF-8"
Approver answered 26/8, 2012 at 19:47 Comment(0)
G
10

I have resolved the issue. The Scala compiler has a different set of options that likely does not subdue to the global Eclipse options. So by going to Preferences->Scala->Compiler and adding -Dfile.encoding=UTF-8 to the Additional command line parameters field I have fixed the error.

Galiot answered 7/2, 2012 at 15:1 Comment(6)
This is a bug (or at least a feature request). You should report this on assembla.com/spaces/scala-ide/tickets.Assemble
I cannot add a ticket there.. even if I login with my google account, the "New Ticket" button does not appear.Galiot
There seems to be a problem with the google login. Try registering under a different usernameAssemble
@MatthewFarwell: Nope, I have tried that and I have been waiting while they fix the problem, but still I cannot see the "New Ticket" button. Strange, really..)Galiot
I'm having the same problem, but adding -Dfile.encoding=UTF-8 didn't fix the problem.Stegosaur
@FilipeRoberto are you sure, you're adding the param to the compiler command line? Sorry I have long moved to Clojure and unaware of the current workings of Scala IDE, so I cannot give you any exact advice :) But the general point is that the Scala compiler should invoke Java compiler with that parameter. You may have to look for the exact way of implementing it today... You can also try setting global Java compiler parameters, hoping they'll be effective. Also please consider complementing the accepted reply with your solution if you find it :)Galiot

© 2022 - 2024 — McMap. All rights reserved.