Eclipse Overview

  1. Start Eclipse
    download oxygen from www.eclipse.org
  2. File, New Java Priject
  3. Name it Lab1
  4. Right Click, new Class
  5. Name it
  6. Add:
    public static void main(String[] args) {
    	}
    
  7. Add:
    System.out.println("TESTING\n");
    
  8. Click on Green arrow to run
  9. Place the following as first line:
    import java.util.Scanner;
  10. Place the following in main:
    	int i;
    	double d;
    	String s1, s2;
    	Scanner sc = new Scanner(System.in);
    	System.out.print("Enter an integer: ");
    	i = sc.nextInt();
    	System.out.print("Enter a floating point value: ");
    	d = sc.nextDouble();
    	System.out.print("Enter a string: ");
    	s1 = sc.next();
    	System.out.print("Enter a string terminated by a newline: ");
    	s2 = sc.nextLine();
    	System.out.println("Here is what you entered: ");
    	System.out.println(i);
    	System.out.println(d);
    	System.out.println(s1);
    	System.out.println(s2);
    
  11. change Scanner to open a file:
    Scanner sc = new Scanner(new File("junk.txt"));
  12. import java.io.*
  13. main needs to throw FileNotFoundException
    public static void main(String[] args) throws FileNotFoundException {
  14. Create file with integer, float, and 2 string
  15. Drag file to Lab1