![]() |
Java
Tips 'n Tricks
|
Have a tip or trick that you've discovered?
Send it to me in an email and I'll post it on this page. Gifs and sample code
is always appreciated. peterj@sctc.mnscu.edu
| Getting error messages? |
| Look at my Java Error page for some things you can try. |
|
|
| Watch out for the duplicate file names. |
| Each chapter has example classes, Example_1, Example_2, Example_3. If you put these on the same disk or directory you will overwrite examples from other chapters. |
|
Suggestion: Set up a naming structure so you can keep all of your sample files for reference and cut and pasting. You could use a folder named "work" to hold all the example
files. Remember, the name of the class in your program has to match the name of the file saved to your disk. If you name a file ch01Ex1.java you have to name the class the same:
|
| Load DOSKEY automatically when you run DOS. |
|
In the DOS window type DOSKEY and then hit ENTER. DOSKEY remembers what you type in a DOS window. Just use the up and down arrows to display commands you've already typed. It's a great feature to have when running the same program over and over. For more information: http://windows.about.com/library/tips/bltip461.htm. |
| To load DOSKEY automatically just add a line to your AutoExec.bat file with the command DOSKEY. Don't forget to reboot your computer so the new AutoExec.bat will run. |
| Naming Conventions |
| keep names short and descriptive |
| Remember: Upper/lower case matters! myInput is different than MyInput |
| Weird file names from text editors |
| Most text editors try to be helpful by adding the extension ".txt" to the end of the file name. If you aren't careful you will end up with a filename like this: HelloWorld.java.txt which won't compile. |
|
To prevent this from happening I suggest putting quotes around the filename
you want. Make certain you include the extension! You can also simply change the file type to All Files (*.*). |