Java Reference
In-Depth Information
The number 2 after the name of the Java source file indicates the line that triggered the
compiler error. With a text editor that supports numbering, you can go directly to that line
and start looking for the error.
Usually there are better ways to debug a program with a commercial Java programming
package, but kit users must search for compiler-generated errors using the line number
indicated by the javac tool. This is one of the best reasons to move on to an advanced
Java development program after learning the language with the kit.
Another alternative is to use the kit with a programmer's text editor
that offers line numbering and other features. One of the most
popular for Java is jEdit, a free editor available for Windows, Linux,
and other systems at the website http://www.jedit.org.
I can personally recommend UltraEdit, an excellent programmer
and web designer's editor that sells for $39.95 at the time of this
writing. To find out more and download a trial version, visit the
website http://www.ultraedit.com.
TIP
Creating a Sample Program
Now that you have installed and set up the Java Development Kit, you're ready to create
a sample Java program to make sure that it works.
Java programs begin as source code—a series of statements created using a text editor
and saved as a text file. You can use any program you like to create these files, as long as
it can save the file as plain, unformatted text.
The kit does not include a text editor, but most other Java development tools include a
built-in editor for creating source code files.
Run your editor of choice and enter the Java program in Listing A.1. Make sure all the
parentheses, braces, and quotation marks in the listing are entered correctly and capitalize
everything in the program exactly as shown. If your editor requires a filename before you
start entering anything, call it HelloUser.java .
LISTING A.1
Source Code of HelloUser.java
1: public class HelloUser {
2: public static void main(String[] arguments) {
3: String username = System.getProperty(“user.name”);
4: System.out.println(“Hello “ + username);
5: }
6: }
 
 
Search WWH ::




Custom Search