|
|
|
Downloading and Installing SoftwareInstalling Sun's Free JavaInstall the Java Run-time Environment (JRE) and J2SE. A Better Development Environment for NT/Win2KIt is possible for NT/Win2K users to use notepad. However, see our installation instructions for
Check out the online books and documentation on Java. Compiling Your First ProgramYou can simply compile the program below with these simple commands
Note the missing file extension on the second command. This is very important. A Better Hello World ProgramNote that his must be stored in a file called ConsoleInput.java. Case is important even if you are working on a Microsoft platform. You many download this to save typing.
/* 1*/// Demonstrate basic console I/O
/* 2*/ /* 3*/import java.io.*; /* 4*/public class ConsoleInput { /* 5*/ public static void main(String args[]) { /* 6*/ BufferedReader in=new BufferedReader( /* 7*/ new InputStreamReader(System.in)); /* 8*/ PrintStream out=System.out; /* 9*/ try{ /*10*/ out.print("What is your name? "); /*11*/ String name = in.readLine(); /*12*/ if(name == null) /*13*/ out.println("No name! end of file detected"); /*14*/ else /*15*/ out.println("Hello there "+name); /*16*/ } /*17*/ catch(java.io.IOException e){ /*18*/ out.println("Java.io.IOException: "+e.toString()); /*19*/ } /*20*/ } /*21*/} Compiling with the JDEStart emacs and use the command c-x c-f to open a new or existing file. In
this case we want to edit Now issue the command c-c c-v c-c to compile. If there are any syntax errors, emacs will position you to the position of the error in response to c-x ` (that last character is known as a backquote or grave and often resides below the ~ character). If you have no errors, you may now run your program by typing c-c c-v c-r and observer the results. |
|
Send mail to
webmaster@SIGNITEK.com with
questions or comments about this web site.
|