Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Help running a very very very simple code

Reply
Thread Tools

Help running a very very very simple code

 
 
olivier.melcher
Guest
Posts: n/a
 
      05-12-2008
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!
 
Reply With Quote
 
 
 
 
Aryeh M. Friedman
Guest
Posts: n/a
 
      05-12-2008
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
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      05-12-2008
"olivier.melcher" <(E-Mail Removed)> 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.

 
Reply With Quote
 
fchang@cs.ubc.ca
Guest
Posts: n/a
 
      05-12-2008
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



 
Reply With Quote
 
Tom McGlynn
Guest
Posts: n/a
 
      05-12-2008
On May 12, 9:14 am, "olivier.melcher" <(E-Mail Removed)>
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
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-12-2008
http://www.velocityreviews.com/forums/(E-Mail Removed)-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/

 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-12-2008
Sabine Dinis Blochberger <(E-Mail Removed)> writes:
>When programming, always stick to plain text.


It was plain text

http://en.wikipedia.org/wiki/Text_file

(assuming that the encoding that was set for the java tools
contains all character codes used). It just used the wrong
characters.

There is nothing wrong, however, with using a visual
programming language, like LabView, in which case one does not
use plain text for programming.

http://upload.wikimedia.org/wikipedi...abVIEWCode.png

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-12-2008
On Mon, 12 May 2008 06:14:06 -0700 (PDT), "olivier.melcher"
<(E-Mail Removed)> 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/compileer...LEGALCHARACTER

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
 
Reply With Quote
 
Oliv
Guest
Posts: n/a
 
      05-12-2008
On May 12, 3:32*pm, (E-Mail Removed)-berlin.de (Stefan Ram) wrote:
> "olivier.melcher" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with a Very, Very Simple Program Max Norman Ruby 5 07-17-2009 03:52 AM
CGI.PM Very very simple question AMT2K5 Perl Misc 3 12-02-2005 05:18 PM
very very very long integer shanx__=|;- C Programming 19 10-19-2004 03:55 PM
Quick Book file access very very very slow Thomas Reed Computer Support 7 04-09-2004 08:09 PM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments