• Post Reply Bookmark Topic Watch Topic
  • New Topic

compile errors  RSS feed

 
K. Joshua Chi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programming can tire out a person. My compiler almost never works. How do I know what errors are in my sourcefile? Since the compiler never shows the errors how are my supposed to know what section of the code my bug is?
Is there a solution to finding out bugs without using IDEs? I am still a very beginner novice.

[ case of subject changed -ds ]
[ September 24, 2004: Message edited by: Dirk Schreckmann ]
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My compiler almost never works.

No offence.. but I don't think it's your compiler that has a problem
(unless you've made it yourselfe)

How do I know what errors are in my sourcefile?


Take a look at the output of your compiler!

Give me an example of what your compiler says, and I'll reply
back.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learning to understand compiler errors is a very good skill to master, and it should be one of the first things a new Java developer learns to do.

When you're looking at the compiler errors, concentrate on the very first thing the compiler complained about. The message generally includes good information about the error encountered, including on what line number the problem was encountered.

If you happen to have more compiler errors than fits in your console buffer (so you can't just scroll up to look at the first thing output), then you can direct output to a text file, instead of to the console. The following command direct the output to the file results.txt.

javac Foo.java > results.txt

I program in baby steps. I use a fancy IDE that checks my syntax constantly. So, I don't write more than one or two lines of code without knowing that what I'm working on will compile. Even if you're using a simple development environment, using notepad to edit and the command line to compile, I recommend that you do the same thing. Write one or two lines of code, and then see if it compiles. You'll get quick at it, especially if you learn a few keyboard short cuts. (If you're on Windows, Alt+Tab switches between program windows. At the command prompt, you can use the up and down arrow keys to browse through recent commands.)

As Svend noted, feel free to post relevant error messages and code examples. Many folks around here will be glad to nudge you in the right direction.
[ September 24, 2004: Message edited by: Dirk Schreckmann ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!