• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Error Code

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 3064
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 22
Mac Netbeans IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 80123
416
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded Sublime Text and it worked perfectly the first try. Thanks Bear.
 
Always look on the bright side of life. At least this ad is really tiny:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic