Compiling Failure
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I know nothing about text editors for Macs. On Windows®, I’d try jEdit, Notepad++ or Notepad2.
And welcome to the Ranch

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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).
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.

-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I'm deeply confused.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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!
| Good night. Drive safely. Here's a tiny ad for the road: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










