Current Topic: 1.2.2. The First Project and the First class
You have a privilege to create a quiz (QnA) related to this subject and obtain creativity score...
Open Eclipse and, when it will ask you to enter a WORKSPACE name, type: C:\ITS Eclipse will create this directory for you and all your projects (that you create later) will be located in this directory.
Then, browse around the Welcome window and feel free to kill (close) the Welcome window. You can always read help pages any time later.
But now, we will create the very first project. Please pay close attention to the instructions as well as to illustrations.
Select the FILE option from the menu at the top and use the following choices:
FILE - NEW - PROJECT - Java Project.
Name the project as week1 Each week we will create a new project and we will name it by the week number. This will make an easy navigation for our future work. Go with the default options to finish creating the project.
After creating a project, take a look at the left pane. You will see the week1 project.
Click on the project to open and you will see the src directory. Do right-mouse click on the src-directory and create a new package day1.
Right-mouse click on the day1 and create the First class.
Follow the illustration below and type the public static void main(String[] args) {
Press ENTER and you will see that Eclipse provides for you the closing braces.
Type in between the braces you first source as:
System.out.println("Welcome to JavaSchool!");
This is your first source. Can you run it? What would it do?
Was it clear so far?
Place the mouse on the source page and do right-mouse click. Select RUN AS ? Java Application.
Eclipse will run it for you and you will see in the CONSOLE window that your program produces this sentence: Welcome to JavaSchool! Done!!! Congratulations!
This note is for the case when this exercise did not go as smooth as expected. If you have a red exclamation sign ! near your project, the most probable cause is a disagreement between your two options in the project properties. Do right mouse click on the project name and select Properties at the bottom. On the Properties you will find two options: Java Build Path and Java Compiler. Make sure that both point to the same Java version.
And this is the illustration on how you run your first source with Run As - Java Application.
Assignments:
a) Create another class, with the name Second, under the same package day1.
b) Create the main method with several lines that will display the names of the levels in the course.
You will use the lines with System.out.println(?) ; Remember to provide quotes around the text you try to display. And remember to finish each line with the semicolon;
c) Do right-mouse click on the source and Run As ? Java Application. You should see how your program displays your lines in the CONSOLE window.
d) Try to misspell some program lines. You will see that Eclipse marked misspelled places with red.
Fix errors and Run As - Java Application again.