We'll start with the most basic environment preparation and the first program, which prints the text "Hello world!".
Java is usually installed on each computer, and in most cases it can be achieved through the command line. To run Java program needed so called JRE (Java Runtime Environment). However, creating the software code and compile it JRE is not enough, we require the JDK (Java Development Kit).
Java version check
To check if Java is installed on your computer and what its version, the easiest way to do this through the Windows Command Prompt.
1. Start the Windows command prompt. In Windows 7 operating system select the Start button and in the program files search box we put the command cmd and press Enter
The Command Prompt window open.
2. In the window, we enter command java -version
We see that the installed Java version is 1.7.0_21.
Installing Java Eclipse IDE
In order to program with Java, usually text editor such as Notepad is and installed JDK is enough. But most often certain programming IDE (Integrated Development Environment) is used. In the market there are not one IDE - commercial and free (IntelliJ, Eclipse, NetBeans, Jdeveloper et al.), And they are selected according to specific problems being solved or programmer taste.
We will use the Eclipse IDE. It is typically used by professional programmers and has many opportunities for extension through plug-ins system.
Eclipse can be downloaded from their site http://www.eclipse.org/downloads/
Page provides several for different purposes configured versions. The version is selected depending on the target what will be done. We choose EE version (Eclipse IDE for Java EE Developers), ie for the Java Enterprise Edition application development.
To install Eclipse, you simply need to extract the zip file contents. The tool is started launching file \eclipse\eclipse.exe
Eclipse the source code you create and their configurations will keeps in a directory so called workspace. For the first time before starting the Eclipse you need to create a new directory for it.
Let's download, install and launch the IDE Eclise
1. Download the Eclipse IDE archive from the site http://www.eclipse.org/downloads/ Select the "Eclipse IDE for Java EE Developers".
2. Create the directory C:\Development\LearnJava\
3. Extract the downloaded Eclipse zip file contents to C:\Development\LearnJava\directory
4. Creating a directory C:\Development\LearnJava\workspace\ for learning project workspace.
Now in C:\Development\LearnJava directory should be two subdirectories eclipse and workspace:
5. Let's start Eclipse. For that we launch the file C:\Development\LearnJava\eclipse\eclipse.exe
6. Workspace selection window opens. In this window:
6.1 enter workspace directory C:\Development\LearnJava\workspace
6.2. check the "Use this as the default and do not ask again" checkbox indicating that this workspace is used by default. If this checkbox is unchecked, every time starting Eclipse you will need to select workspace.
6.3. press the "OK" button.
7. Eclipse IDE window opens
In Eclipse (as in most other Java IDE) software code is grouped into projects. Eclipse to facilitate the development of new projects and the initial configuration has a number of standard project templates. They are chosen by a problem, which we want to solve, technology and other nuances.
We are going to create a system for Car Rental Company.
Let's create a project.
1. We close Welcome window
2. In menu we select File -> New -> Project...