• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error Code  RSS feed

 
Michael Ruebusch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when writing my first "Hello World" app everything seemed to work just fine. I wrote the code, compiled it, and then ran the class file and it worked, I got the return Hello World! But when I tried to write another app which is basically the exact same thing just a different sentence, I keep getting a bunch of error codes saying illegal character. I did everything the exact same. I am using Text Edit on a Mac and using Terminal to execute the Java code. Here is what I wrote....

public class MyFirstApp
{
public static void main( String[] args )
{
System.out.println(“i rule the world!”);
}
}

When I type javac MyFirstApp.java in Terminal, I get this response....
Michaels-iMac:java michaelruebusch$ javac MyFirstApp.java
MyFirstApp.java:5: error: illegal character: '\u201c'
System.out.println(“i rule the world!”);
^
MyFirstApp.java:5: error: ';' expected
System.out.println(“i rule the world!”);
^
MyFirstApp.java:5: error: ';' expected
System.out.println(“i rule the world!”);
^
MyFirstApp.java:5: error: not a statement
System.out.println(“i rule the world!”);
^
MyFirstApp.java:5: error: ';' expected
System.out.println(“i rule the world!”);
^
MyFirstApp.java:5: error: illegal character: '\u201d'
System.out.println(“i rule the world!”);
^
6 errors

Anyone have any thoughts?
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somehow, you've got the fancy open and close quotation marks, instead of the normal quotation marks Java uses to delimit strings. Are you using a word processor like Word or Word Pad to write your code?
 
Steve Kedzie
Greenhorn
Posts: 22
Mac Netbeans IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'\u201d' is Unicode for "right double quotation mark" and just may be your culprit as Greg pointed out. If you are using Windows, I recommend using a text editor like Sublime or Notepad++. Both are free (Sublime asks you to register after so many saves, but you can cancel and keep using the software) and Java friendly. Sublime is also available for Linux. TextWrangler is popular among Mac users.
 
Michael Ruebusch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Text Edit on my Mac. I formatted it to be plain text. I don't know why it isn't working. It worked just fine for the fist program that I wrote, but not this one. I didn't think I did anything different. Does anyone have any ideas for Mac, not windows?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sublime Text works great on the Mac. TextMate is also popular, though I've never used it.

I personally use IntelliJ IDE, but you may not want a full IDE yet.

TextEdit is not a good choice -- it's not a code editor.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You don't usually need to search for editors if you use Linux; gedit/pluma and Kate are good editors and you usually have one or the other built in.
 
Michael Ruebusch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded Sublime Text and it worked perfectly the first try. Thanks Bear.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!