p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   JSP Basics (http://p2p.wrox.com/forumdisplay.php?f=92)
-   -   Java 2 j2sdk1.4.2 for linux problem (http://p2p.wrox.com/showthread.php?t=24986)

dglnz February 3rd, 2005 03:29 AM

Java 2 j2sdk1.4.2 for linux problem
 
Well starting to get my feet wet after @ 3 attempts at it last year.

did a simple OurFirstProgram (code below) and getting errors!!!

public class OurFirstProgram
{
    public static void main(String[] args)
    {
       System.out.println(¨this is my first program !¨);

Errors seem to be related to how i have quoted the string text
I have tried NO qoutes, single quotes and as seen above double quotes
and each give the same errors and error nos.

Is this because i HAVE got to use the JDK or the updated sdk and not the net beans version ?? (tho i think alls i have done is put the java 2 sdk under the netbeans dir).

    }
}

errors as per terminal screen are ....

[dave@localhost my console java apps]$ /home/j2sdk_nb/j2sdk1.4.2/bin/javac OurFirstProgram.java
OurFirstProgram.java:5: illegal character: \168
           System.out.println(¨this is my first program !¨);
                              ^
OurFirstProgram.java:5: illegal character: \168
           System.out.println(¨this is my first program !¨);
                                                         ^
OurFirstProgram.java:5: ')' expected
           System.out.println(¨this is my first program !¨);
                                                           ^
3 errors

rbonslat February 3rd, 2005 04:33 AM

Those weren't quotes, I'm not sure what those were. You also need two closing brackets. Here:

public class OurFirstProgram
{
    public static void main(String[] args)
    {
       System.out.println("this is my first program !");
   }
}


dglnz February 3rd, 2005 04:58 AM

 [?][?][?]

Quote:

quote:Those weren't quotes, I'm not sure what those were. You also need two closing brackets. Here:

public class OurFirstProgram
{
    public static void main(String[] args)
    {
       System.out.println("this is my first program !");
   }
}
sorry but where do the brackets go ???

to explain further...

I purchased a copy of java 2 beginning by Ivor Horton and on page28 i copied his 1st sample program. as below (without my comments).

Code:

public class OurFirstProgram
{
    public static void main(String[] args)
    {
       System.out.println(¨this is my first program !¨);
    }
}

the errors are about the quotation marks and tried to see if i could solve this my tring no quotes or single quotes. hense the second question (maybe not so clearly written) which is ...

because i installed netbeans ide and even tried it under that enviroment (and getting the simlar errors) I wanted to know if i should install the proper SDK rpm (running Mandrakelinux which is the compiled install program).

dglnz February 5th, 2005 06:15 AM

Quote:

quote:Originally posted by rbonslat
 Those weren't quotes, I'm not sure what those were. You also need two closing brackets. Here:

public class OurFirstProgram
{
    public static void main(String[] args)
    {
     System.out.println("this is my first program !");
}
}


done some investigation via a hex editor.

would be interested if you could tell me the hex value you get for a double quote.

In my Mandrake 10.0 system it gives me Hex 22 (in code i got off a CD) but in my code (sample i had posted) it was ab Hex.

so maybe something is going wrong on my keyboard.

cheers.

dave.

rbonslat February 5th, 2005 12:24 PM

Let me see how to explain this. I don't think it has anything to do with Java SDK. I copied, pasted and compile your exact same code on my text editor and it gave me this:

C:\Documents and Settings\Robert\Desktop\OurFirstProgram.java:5: illegal character: \168
       System.out.println(¨this is my first program !¨);
                          ^
C:\Documents and Settings\Robert\Desktop\OurFirstProgram.java:5: illegal character: \168
       System.out.println(¨this is my first program !¨);
                                                     ^
C:\Documents and Settings\Robert\Desktop\OurFirstProgram.java:5: ')' expected
       System.out.println(¨this is my first program !¨);
                                                       ^
3 errors

this seems to be the same error message 168 to me. Now when I deleted the imposter quotes that you have and added real quotes, it compiled successfully.

public class OurFirstProgram
{
    public static void main(String[] args)
    {
       System.out.println("this is my first program !");
   }
}



rbonslat February 5th, 2005 12:28 PM

It is obvious you have a keyboard malfunction. Try going on the internet to find out what the issue is.


dglnz February 16th, 2005 12:52 AM

Hi there,

I am tending to agree with you (that the Quotes are the problem).

infact i had thought this right from the beinging and was wanting someone to confirm my suspections.

Since starting this thread I placed my problem on a more local (to where I live) list and got the same answer/replies.

Tried using sun beans 3.6 ide got the same errors.

Oh well time to think (might see if i can get a loan of a keyboard) from work over the weekend as this might solve my problem.

thanks to all who have helped me with this issue.


All times are GMT -4. The time now is 02:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.