7 Replies Latest reply: Jun 17, 2009 1:58 AM by PhHein RSS

    help with illegal character thing

    843785
      im just starting to java, im reading as much as i can, i bought a cbt nuggets cd & im running the next code ( its from the very first lessons), it is exactly the same as on the videos, but it is not compiling, the only difference is that im running vista home basic with JDK(SE) 1.6.0_11 & in the cbt videos the trainer runs XP with JDK (SE) 1.4,2_05 would that have something to do ?? i would really appreciate your help . Thanks a lot !!
      <code>
      public class math1

      {      
      public static void main(String[] args)

      { int a = 5 ;
      int b = 7 ;
      int c = a + b ;

      System.out.println(c);
      }
      }
      and this is what came up in the cmd :

      C:\Program Files\Java>javac math1.java
      math1.java:1: illegal character: \0
      &#9632; p u b l i c c l a s s m a t h
      ^
      math1.java:1: illegal character: \0
      &#9632; p u b l i c c l a s s m a t h
      ^
      math1.java:1: illegal character: \0
      &#9632; p u b l i c c l a s s m a t h
      ^
      math1.java:2: illegal character: \0

      ^
      math1.java:3: illegal character: \0


      ^
      math1.java:5: illegal character: \0

      ^
      math1.java:6: illegal character: \0

      ^
      math1.java:7: illegal character: \0
      {
      ^
      math1.java:7: illegal character: \0
      {
      ^
      math1.java:7: illegal character: \0
      {
      ^

      .... And so on marking several errors in every line

      83 errors
        • 1. Re: help with illegal character thing
          843785
          What did you write your code in? Did you type it out manually or paste it from someplace?
          • 2. Re: help with illegal character thing
            843785
            binary_coder wrote:
            What did you write your code in? Did you type it out manually or paste it from someplace?
            Good point. Could it be WordPad or some other editor that doesn't save the text in standard ascii format?
            • 3. Re: help with illegal character thing
              843785
              Solaris_Phoenix wrote:
              im just starting to java, im reading as much as i can, i bought a cbt nuggets cd & im running the next code ( its from the very first lessons), it is exactly the same as on the videos, but it is not compiling, the only difference is that im running vista home basic with JDK(SE) 1.6.0_11 & in the cbt videos the trainer runs XP with JDK (SE) 1.4,2_05 would that have something to do ??
              The code you posted should run on anything with a JRE. The illegal character error is not part of your syntax, it is a physical character that the compiler cannot interpret. As asked by other posters, did you cut and paste the code? If so you may have aquired a character that cannot be interpreted due to conversion to the different versions of the OS, or tools used by the Author, or that you are now using.

              I've been able to successfully copy and paste text files from text editors and IDE's across plaforms in Windows 2003, Me, XP, Vista, Solaris, and Ubuntu. Try typing into an IDE or using NotePad and see if your problem clears.
              • 4. Re: help with illegal character thing
                794029
                Solaris_Phoenix wrote:
                im just starting to java, im reading as much as i can, i bought a cbt nuggets cd & im running the next code ( its from the very first lessons), it is exactly the same as on the videos, but it is not compiling, the only difference is that im running vista home basic with JDK(SE) 1.6.0_11 & in the cbt videos the trainer runs XP with JDK (SE) 1.4,2_05 would that have something to do ?? i would really appreciate your help . Thanks a lot !!
                public class math1
                
                {      
                public static void main(String[] args)
                {
                int a = 5 ;
                int b = 7 ;
                int c = a + b ;
                
                System.out.println(c);
                }
                }
                and this is what came up in the cmd :

                C:\Program Files\Java>javac math1.java
                What you have should work..
                (and what everyone else said is probably right)

                Try copying what you have posted in the fourms, and put it in wordpad/notepad (maybe sun's Fourms will fix it? lol)
                (or just re-type it into a wordpad/notepad)

                Edited by: 00jt on Jan 3, 2009 5:36 PM
                • 5. Re: help with illegal character thing
                  843785
                  Thank you all for your answers i really apreciate them , i think i discovered what was the problem , i executed cmd as administrator thru task manager, and when compiled program had no issues, then ran it , worked prefectly!!
                  • 6. Re: help with illegal character :\ 0 when compiling a java program
                    843789
                    I am also new at java , I was trying to comlpile my program and i got this error message :

                    illegal character :\ 0

                    100 errors

                    Please help to sort sort this out.
                    • 7. Re: help with illegal character :\ 0 when compiling a java program
                      PhHein
                      OLGANO, please don't resurrect old threads. Feel free to start a new thread and make sure you include your code using the code tags.

                      Locking.