Title: Development Environment
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

Development Environment

Installing a Java environment:

We will be using Eclipse as our development environment for this class. Eclipse provides a nice user interface for learning Java. You should find Eclipse and java already installed on many WCC computers. In this section we will go over the basics of using these tools as well as where to download this free software.

First we will want to make sure you have the Java software installed on your computer. To install Java software, first go to the link:

http://www.oracle.com/technetwork/java/index.html

- Under "Top Downloads", click on Java SE (Standard Edition).
- Follow Java Download link and pick your platform. Older PCs that don't support 64-bit architecture should choose the Windows x86 option. I run a windows 7 PC, and the 64 bit option works fine. In the video I actually chose a Windows x86 which should work on all windows platforms.
- You will download the file and double click on it to run it.
- Take all of the normal default type of operations.

Using Eclipse

Normally, we will do our work within the Eclipse environment, because Eclipse will assist us in many ways in our Java programming efforts.

Go to the web address:
www.eclipse.org

Select the Download Eclipse link and download the "Standard Eclipse" version. If your Java is 64-bit based, choose the 64-bit version of Eclipse. Otherwise choose the 32-bit version of Eclipse.

We will be demoing the following important features in Eclipse :

- Create a Java Project
- Create Class files for each Java Class. You might want to check the box that automatically adds the main method.
- Run your class as a Java application.
- Your program will put output in the Console window. If you collect keyboard input, it needs to be entered in the Console window.

You can use the following program as a simple test program in the above exercises:

Hello program


   import java.util.Scanner;

   class Hello {
       public static void main(String[] args){
             System.out.println("hello world ... Enter your name");

             Scanner keyboard = new Scanner(System.in);
             String input = keyboard.nextLine();
             System.out.println("Hello: " + input);

       }
     }


Running your Java development tools outside of Eclipse

Run the command(DOS) tool from the Start_Button/Accessories. Note the directory that prints out as the current working directory when you start this tool up.

Find out the "bin" directory of your Java development tools ... it should be something like: c:\Program Files (x86)\Java\jdk1.7.0_05\bin

Issue a path command to tell the DOS environment where to find your Java tools. This command should basically add the Java bin directory to the front of the normal path used in the DOS command. tool. The command should look something like:
path=c:\Program Files (x86)\Java\jdk1.7.0_05\bin;%path%

If you have the path command correctly, you should be able to issue the Compiler command which will print out your compiler options:
javac

Next you will want to add a Java program to test out. You can use notepad to put this program in the current working directory where your DOS command tool is running. You can try out the following program:


import java.util.Scanner;

class Hello
{
   public static void main(String[] args)
   {
       System.out.println("hello world ... Enter your name");

       Scanner keyboard = new Scanner(System.in);
       String input = keyboard.nextLine();
       System.out.println("Hello: " + input);

   }
}


To compile the program, issue the command:
javac Hello.java

To execute the program, issue the command:
java Hello

To see the executable output of the compiler (Hello.class), issue the DOS command:
dir

Exercises:

- Use the above notes to install the latest Java JDK and run a simple program
- Install Eclipse and run a simple program
- For fun: For fun, download the following program created by one of my CPS261 students ... This needs some explaination and a demo:
planetoid.jar
From your command line issue the command:
java -jar planetoid.jar

Last Modified: August 11, 2014 2:02 PM