Help running a very very very simple code

Discussion in 'Java' started by olivier.melcher, May 12, 2008.

  1. Hi,

    i'm started with Java Programming, i'm trying to run a very simple
    sample code.

    Can anyone tell me why it's not compiling right?

    I'm running Netbeans IDE 6.1 with Java JDK 6 on Linux OS (Ubuntu).

    I've got the Java API Documentation placed in my Java Home Directory (/
    home/olivier/jdk1.6.0_06/docs)

    Here is the code:

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package myfirstproject;

    /**
    *
    * @author olivier
    */
    class MyFirstJavaClass {
    /**
    * Method main
    *
    *
    * @param args
    *
    */
    public static void main(String[] args) {
    System.out.println(“chocolate, royalties, sleep”);
    }
    }


    Here is the error message i get when trying to compile the code:

    init:
    deps-jar:
    Compiling 1 source file to /home/olivier/NetBeansProjects/
    MyFirstProject/build/classes
    /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    MyFirstJavaClass.java:21: illegal character: \8220
    System.out.println(“chocolate, royalties, sleep”);
    /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    MyFirstJavaClass.java:21: ';' expected
    System.out.println(“chocolate, royalties, sleep”);
    /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    MyFirstJavaClass.java:21: illegal start of expression
    System.out.println(“chocolate, royalties, sleep”);
    /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    MyFirstJavaClass.java:21: illegal character: \8221
    System.out.println(“chocolate, royalties, sleep”);
    4 errors
    BUILD FAILED (total time: 0 seconds)


    Thanks for the help!
     
    olivier.melcher, May 12, 2008
    #1
    1. Advertising

  2. olivier.melcher wrote:
    > Hi,
    >
    > i'm started with Java Programming, i'm trying to run a very simple
    > sample code.
    >
    > Can anyone tell me why it's not compiling right?
    >
    > I'm running Netbeans IDE 6.1 with Java JDK 6 on Linux OS (Ubuntu).
    >
    > I've got the Java API Documentation placed in my Java Home Directory (/
    > home/olivier/jdk1.6.0_06/docs)
    >
    > Here is the code:
    >
    > /*
    > * To change this template, choose Tools | Templates
    > * and open the template in the editor.
    > */
    >
    > package myfirstproject;
    >
    > /**
    > *
    > * @author olivier
    > */
    > class MyFirstJavaClass {
    > /**
    > * Method main
    > *
    > *
    > * @param args
    > *
    > */
    > public static void main(String[] args) {
    > System.out.println(“chocolate, royalties, sleep”);
    > }
    > }
    >
    >
    > Here is the error message i get when trying to compile the code:
    >
    > init:
    > deps-jar:
    > Compiling 1 source file to /home/olivier/NetBeansProjects/
    > MyFirstProject/build/classes
    > /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    > MyFirstJavaClass.java:21: illegal character: \8220
    > System.out.println(“chocolate, royalties, sleep”);
    > /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    > MyFirstJavaClass.java:21: ';' expected
    > System.out.println(“chocolate, royalties, sleep”);
    > /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    > MyFirstJavaClass.java:21: illegal start of expression
    > System.out.println(“chocolate, royalties, sleep”);
    > /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    > MyFirstJavaClass.java:21: illegal character: \8221
    > System.out.println(“chocolate, royalties, sleep”);
    > 4 errors
    > BUILD FAILED (total time: 0 seconds)
    >
    >
    > Thanks for the help!


    What happens if you compile from the command line:

    cd /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    javac MyFirstJavaClass.java
    java MyFirstJavaClass
     
    Aryeh M. Friedman, May 12, 2008
    #2
    1. Advertising

  3. olivier.melcher

    Stefan Ram Guest

    "olivier.melcher" <> writes:
    >package myfirstproject;


    Simple »Hello, world« programs do not need to have
    a package, while this is good for most real work.

    >System.out.println(chocolate, royalties, sleep);


    You should use character 43 (»"«) instead of character 147
    and 148 (both omitted in the quotation above) around the text.
     
    Stefan Ram, May 12, 2008
    #3
  4. olivier.melcher

    Guest

    On Mon, 12 May 2008, Aryeh M. Friedman wrote:
    >
    > olivier.melcher wrote:
    > > package myfirstproject;
    > >
    > > class MyFirstJavaClass {
    > > public static void main(String[] args) {
    > > System.out.println(“chocolate, royalties, sleep”);
    > > }
    > > }

    >
    > What happens if you compile from the command line:
    >
    > cd /home/olivier/NetBeansProjects/MyFirstProject/src/myfirstproject/
    > javac MyFirstJavaClass.java
    > java MyFirstJavaClass


    Actually, since the class is under the "myfirstproject" package,
    the legal way to compile it from the command line must be done
    from the directory ABOVE it:

    cd /home/olivier/NetBeansProjects/MyFirstProject/src/
    javac myfirstproject/MyFirstJavaClass.java
    java -cp . myfirstproject.MyFirstJavaClass
     
    , May 12, 2008
    #4
  5. olivier.melcher

    Tom McGlynn Guest

    On May 12, 9:14 am, "olivier.melcher" <>
    wrote:
    ...
    > System.out.println(“chocolate, royalties, sleep”);

    ...

    The error messages and the way the line above renders for me, suggests
    that you might want to check if you have a pair of forward and
    backward quotes here rather than just two simple double quotes.
    Perhaps the editor your installation of NetBeans uses converts pairs
    of quotes this way (a la Word).

    Regards,
    Tom McGlynn
     
    Tom McGlynn, May 12, 2008
    #5
  6. olivier.melcher

    Stefan Ram Guest

    -berlin.de (Stefan Ram) writes:
    >You should use character 43 (»"«) instead of character 147
    >and 148 (both omitted in the quotation above) around the text.


    1s/character 43/character 34/
     
    Stefan Ram, May 12, 2008
    #6
  7. olivier.melcher

    Stefan Ram Guest

    Stefan Ram, May 12, 2008
    #7
  8. olivier.melcher

    Roedy Green Guest

    On Mon, 12 May 2008 06:14:06 -0700 (PDT), "olivier.melcher"
    <> wrote, quoted or indirectly quoted someone
    who said :

    >MyFirstJavaClass.java:21: illegal character: \8220
    > System.out.println(“chocolate, royalties, sleep”);


    see
    http://mindprod.com/jgloss/compileerrormessages.html#ILLEGALCHARACTER

    You can often get hints on the meaning and causes of various error
    messages there.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, May 12, 2008
    #8
  9. olivier.melcher

    Oliv Guest

    On May 12, 3:32 pm, -berlin.de (Stefan Ram) wrote:
    > "olivier.melcher" <> writes:
    > >package myfirstproject;

    >
    >   Simple »Hello, world« programs do not need to have
    >   a package, while this is good for most real work.
    >
    > >System.out.println(chocolate, royalties, sleep);

    >
    >   You should use character 43 (»"«) instead of character 147
    >   and 148 (both omitted in the quotation above) around the text.


    Stefan,

    That did the trick, i changed the characters and the program compiled
    and ran perfectly!

    Thanks for your help :)
     
    Oliv, May 12, 2008
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    499
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,678
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    445
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    526
    Dave Thompson
    Feb 14, 2005
  5. Max Norman
    Replies:
    5
    Views:
    141
Loading...

Share This Page