• Post Reply Bookmark Topic Watch Topic
  • New Topic

Illegal character exception for character " in textEdit in Mac  RSS feed

 
Ajinkya Ghonge
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to write some java code without using eclipse. I was able to execute a class with empty main method written in textEdit. However, I am getting illegal character Exception when I use " symbol in my class. I understand that this is due to some encoding issue in textEdit, but I am not able to resolve it. Can someone have a look and advice

Code:


Error:
Zoo.java:3: error: illegal character: '\u201c'
System.out.println(“Zoo”);
^
Zoo.java:3: error: ';' expected
System.out.println(“Zoo”);
^
Zoo.java:3: error: illegal character: '\u201d'
System.out.println(“Zoo”);
^
Zoo.java:3: error: ';' expected
System.out.println(“Zoo”);
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quotes delimiting String literals are supposed to be " i.e. straight quotes. The Unicode escape would be \u0022. What you are using is post quotes \u201c and \u201d which look like this:- “”
You cannot use posh quotes in code; the compiler won't like it. You can use posh quotes inside String and char literals.

The commonest cause for that error is editing your code with a word processor rather than a text editor.

And welcome to the Ranch
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to use TextEdit (not the best choice), make sure that you have the file in plain text mode. You can find this under the Format menu as "Make plain text".

Get yourself a good code editor.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:. . . Get yourself a good code editor.
If you are on a Linux box try pluma or kate; on Windows try NotePad++.
 
Ajinkya Ghonge
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help. I was able to solve the problem by removing the smart quotes from my textEdit.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pleasure
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this question has been resolved, I'm sorry to bump it up again, but I see OP using Mac.
Please go and download TextWrangler for your text editing, programming - very good.

I always think about that second word Wrangler as about american jeans brand, which used to be and probably still is a very good quality (used to have in past)
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:I always think about that second word Wrangler as about american jeans brand, which used to be and probably still is a very good quality (used to have in past)

Which itself comes from the job of "wrangler" from the Old West which, according to Dicitonary.com, may originate from the Spanish caballerango.

Winston
 
Chris Barrett
Bartender
Posts: 321
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another one for Mac that I'm partial to is TextMate.

TextMate takes some getting use to - it's not as pretty at TextWrangler, and is much more keyboard shortcut driven than mouse. Once you get the hang of it, though, it's great.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!