Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
QuickStart Java Learning to Program in Java Dr. Tom Way October 21, 2005 Applied Computing Technology Laboratory The Java Programming Language Developed in 1996 Created by Patrick Naughton, James Gosling and Mike Sheridan (and others) at Sun Microsystems Original called the “Green Project” Uses Object-Oriented paradigm Good for general purpose applications, web apps, databases, etc. Applied Computing Technology Laboratory 2 Java Advantages Platform independence – “write once, run anywhere” Fast prototyping of user interfaces Excellent documentation Great for teaching and learning Increasing in popularity Now used widely in industry Automatic garbage collection Applied Computing Technology Laboratory 3 Java Disadvantages Compile to Java byte code, not native Runs on “virtual machine,” so can be slower than native machine Doesn’t have true multiple inheritance (but can get through multiple interfaces) Some simple things are harder – keyboard input, primitive types vs. Objects Applied Computing Technology Laboratory 4 Java Specification Third edition available on Sun web site http://java.sun.com Explains: Grammar Lexical structure Types, values, variables Type conversions and promotions Packages, classes, interfaces, inheritance Arrays, exceptions, execution, blocks, statements, expressions, assignments, threads, locks Applied Computing Technology Laboratory 5 Java Grammar Available on Sun web site http://java.sun.com/docs/books/jls/third_edition/html/syntax.html#18.1 Example: Type: Identifier [TypeArguments]{ . Identifier [TypeArguments]} {[]} BasicType TypeArguments: < TypeArgument {, TypeArgument} > TypeArgument: Type ? [( extends | super ) Type] Identifier: IDENTIFIER BasicType: byte | short | char | int | long | float | double | boolean Applied Computing Technology Laboratory 6 Identifier Identifier: IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral IdentifierChars: JavaLetter IdentifierChars JavaLetterOrDigit JavaLetter: any Unicode character that is a Java letter JavaLetterOrDigit: any Unicode character that is a Java letter-ordigit Applied Computing Technology Laboratory 7 Step 1: Getting Started Download & install JDK from: http://java.sun.com/j2se/1.5.0/download.jsp Double-click on file to run installer Follow your nose Check online installation instructions for helpful tips Applied Computing Technology Laboratory 8 Step 2: Eclipse Download & install Eclipse from: http://eclipse.org/downloads Unzip to a directory (e.g., C:\eclipse) Create desktop shortcut, if you like Right-click on eclipse.exe Send to -> Desktop (create shortcut) Applied Computing Technology Laboratory 9 Step 3: Write a simple program File->New->Project Select “Java Project” Name project “Hello World” Select File->New->Class Name the class “HelloWorld” (no spaces) Check “public static void main()” box Add one line in the main() method: System.out.println(“Hello world!”); Applied Computing Technology Laboratory 10 Step 4: Run the program Right-click on HelloWorld.java Select Run As->Java Application Watch console at bottom for output Congratulations! Applied Computing Technology Laboratory 11 Learning more about Java Visit the QuickStart Languages web site http://actlab.csc.villanova.edu/quickstart View or download the Java API: http://java.sun.com/j2se/1.5.0/docs/api/index.html Read the Java Developers Almanac http://javaalmanac.com/ Google search for: java program examples Applied Computing Technology Laboratory 12