• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling Failure  RSS feed

 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya!

I've very recently started on my epic quest of Java-tude, but I have come across a major roadblock: upon attempting to compile ANYTHING into a java class or whatnot, well... it just doesn't work. It gives me a long list of errors every time which seems to change each time as well.

Let me explain: I have a Macbook, and I'm automatically "pathed" correctly with Textedit and the terminal/console. I'm probably not explaining myself very well, but that's only because I don't know the proper terminology for all thee things. Anyway, I would type up the code properly (I swear it), and then save the file as ____.java . Then I would go into the terminal/console and type "javac ____.java". This is where I get all those darn errors! I can't paste an example, because it's different every time, but I can tell you that there was a lot of "illegal character: /0", which makes absolutely no sense.

Anyway, I've been struggling with this issue for the past few days, and won't be able to continue learning until I overcome it.

Any help would be greatly appreciated!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that you are saving the file as a text file and not RTF?

TextEdit is a poor tool to be using to write Java source. I'd recommend you download the free TextWrangler if you want to be coding in a text editor.
 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Are you sure that you are saving the file as a text file and not RTF?

TextEdit is a poor tool to be using to write Java source. I'd recommend you download the free TextWrangler if you want to be coding in a text editor.


Thank you for the recommendation!

And yes, I am absolutely POSITIVE it's a text file, and definitely not an .rtf file. I made that mistake already, but it still doesn't work regardless.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is saying illegal character \0 there is something wrong with your text formatting. Try a simple hello world program, such as you can find an a thousand websites. Click “view plain”, ctrl-A ctrl-C and ctrl-V to paste into your text editor. Save it as HelloWorld.java See whether it will compile. If you get the same error, it is a text editor problem.By the way, the character \0 is called the null character. You probably ought not to have it in text files in the first place.
I know nothing about text editors for Macs. On Windows®, I’d try jEdit, Notepad++ or Notepad2.

And welcome to the Ranch
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do not use TextEdit. Period. There are hundreds of editors intended specifically for coding that you can use; one of which I already gave you a link to. Using a tool intended for document processing is going to cause problems.
 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I'm now using TextWrangler, because it's awesome, but I still have the same problem!

I also used HelloWorld.java to test it... and THAT worked. I have no clue why, though. I'm going to have to post the code I used, and the error I got. So here:

CODE ("PhraseOMatic.java"):


And when I do "javac PhraseOMatic.java" in the terminal, I get the "illegal character: \0" error about 100 times.



(PS: I'm using the book "Head First Java: Second Edition", and I copied this code exactly.)

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your original editor probably inserted some garbage characters. Fortunately, when you copied and pasted into the forum, they don't appear to have carried over. I copy/pasted your source code and got a bunch of plain old syntax errors for "not a statement" and "; expected" and suchlike, but none of those illegal character ones.

Rather than opening the already corrupt file with your new editor, start with a new, blank document and copy paste the text in--from your post in this forum, if necessary.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so...

You have a few errors in the above code. There were 3-4 missing quotes in one of your word lists. Then, you declare it as "worldListTwo", but then refer to wordListTwo.

Once I fixed those errors, it compiled and ran just fine. So...the problem is that you have some non-printing character. You need to get rid of them. I would suggest cut-n-pasting it from wherever you have it into a simple text editor, because the code is fine (apart from what I mentioned above).
 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:so...

You have a few errors in the above code. There were 3-4 missing quotes in one of your word lists. Then, you declare it as "worldListTwo", but then refer to wordListTwo.

Once I fixed those errors, it compiled and ran just fine. So...the problem is that you have some non-printing character. You need to get rid of them. I would suggest cut-n-pasting it from wherever you have it into a simple text editor, because the code is fine (apart from what I mentioned above).


Ah, silly me. I'm HORRIBLE at finding errors my self.
 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, now I've fixed all the errors - I fixed the ones Fred mentioned, and a few others I noticed. I looked through very carefully, and saw nothing else wrong. I then did "javac PhraseOMatic.java" in the terminal, and... just more of the "Illegal Character: \0" errors.

I'm deeply confused.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beckett Melville wrote:Well, now I've fixed all the errors - I fixed the ones Fred mentioned, and a few others I noticed. I looked through very carefully, and saw nothing else wrong. I then did "javac PhraseOMatic.java" in the terminal, and... just more of the "Illegal Character: \0" errors.

I'm deeply confused.

did you follow the advice above about starting over in a clean file?
 
Beckett Melville
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:
Beckett Melville wrote:Well, now I've fixed all the errors - I fixed the ones Fred mentioned, and a few others I noticed. I looked through very carefully, and saw nothing else wrong. I then did "javac PhraseOMatic.java" in the terminal, and... just more of the "Illegal Character: \0" errors.

I'm deeply confused.

did you follow the advice above about starting over in a clean file?


Believe it or not, I did. :P

But guess what? I just did it again, and it worked this time! It finally works! I'm so happy, thank you all so much! I can finally start writing proper programs! :'D
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beckett Melville wrote:
fred rosenberger wrote:
did you follow the advice above about starting over in a clean file?


Believe it or not, I did. :P

But guess what? I just did it again, and it worked this time!


Then the first time you only thought you followed the advice, but you forgot to save the file, or saved it somewhere else, or something silly like that.

Glad you got it cleared up now though!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!