Running Eclipse : An example Step 1) Create a folder...

17
Running Eclipse : An example Step 1) Create a folder called Programming 12 on your desktop. Step 2)Open eclipse, it may bring up the following dialogue box: If this box comes up, click on the browse button and choose your folder on your desktop called Programming 12. YOU SHOULDN’T HAVE TO DO THIS STEP AGAIN, if your click on the small checkbox near the bottom left hand corner that says use this as a default. Step 3) Under the window menu make sure the java perspective is chosen. Step 4)Create a new project, lets call it test1.

Transcript of Running Eclipse : An example Step 1) Create a folder...

Page 1: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Running Eclipse : An example Step 1) Create a folder called Programming 12 on your desktop. Step 2)Open eclipse, it may bring up the following dialogue box:

If this box comes up, click on the browse button and choose your folder on your desktop called Programming 12. YOU SHOULDN’T HAVE TO DO THIS STEP AGAIN, if your click on the small checkbox near the bottom left hand corner that says use this as a default. Step 3) Under the window menu make sure the java perspective is chosen.

Step 4)Create a new project, lets call it test1.

Page 2: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 5)Fill in the project name as test1, (when we make programs in this course, I will tell you what to call the various projects) Look at the picture below, you will notice a thick black arrow, which shows one change I would like you to make. You must select, “use project folder as root for sources and class files”. (you can configure default so this option is chosen each time automatically)

Page 3: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your
Page 4: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 6)Click finish on the above dialog box , then a series on sections in a window show up.

Step 7)Make sure your test1 folder is highlighted and then you can right click on it, and select the menu choice: New>>class (Alternatively, you could make sure that test1 folder is highlighted, and then click on the C on the menu bar of icons…. (I have pointed a black arrow towards it on the picture below)

This is where all your projects are listed. Called the package explorer

This is where all the errors and warning about your program problems will show up.

Windows to type in your programs will show up here.

Page 5: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 8: A new dialog shows up. There is only 1 line you need to fill in. The black arrow points to it, give the class name, the same name as your folder (for now).

Page 6: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 9) In the “main” window, some writing shows up with the tab being called test1.java THIS IS YOUR PROGRAMMING CODE. THIS IS WHERE YOU WILL WRITE ALL OF YOUR PROGRAMMING COMMANDS. Each project you create, you will be making a new class, and then writing the code for it.

Page 7: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 10) In the test1.java file window, adjust the code to make it look like the one below. BE CAREFUL, the semi-colons,curly brackets { }, quotations and capitals matter!!. There are several special java words and if spelled incorrectly, the program will not work.

Our programming code will go here. We will be adjusting the code in a minute. The test1.java file

now shows up here,along with some other files which aren’t to be touched by you.

These are { brackets

These are { brackets

These are ( brackets

Page 8: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

The code is written below again for more clarity:

import java.awt.*;

public class test1 extends java.applet.Applet{

public void paint(Graphics screen){

screen.drawString("Hello Mr.Kailley",50,50);

}

} Step 11)Now, the COMPILER must check the program for spelling, word errors. To do this, just save the file, that automatically BUILDS (compiles) the file… If you want to do it manually, make sure the test1 project folder is highlighted and go to the project menu, deselect where is says build automatically , and then you can use CTRL B keys to COMPILE when a file is selected. (I recommend build automatically)

Step 12) Check the problems windows at the bottom for any FATAL ERRORS (don’t worry about warnings). It will display any messages etc…

Page 9: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

**Note, you may want to adjust the code and purposely erase or add in an extra bracket and see what happens when you try to compile the program again! Then fix it and move onto the next step.

This warning always comes up with applets, you can ignore it. But other errors may come up, and the line # containing the error is given.

If you have errors or warnings, an icon is shown beside the line with the error. If you click on that icon, a dialog box shows up with possible SOLUTIONS to your problem!

Page 10: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 13)Now you will create a web page to “show” your applet. Right click on the test1 FOLDER , and then select new file.

Step 14) Fill in the dialog box in the location shown with the black arrow

(leave all else alone). I like to use the same name for web page as the java program name. My file name is test1.html

Page 11: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 15) The following new window shows up in the “main” window

section. (Notice the tabs at the top, test1.java is still available, you just have to click on its tab.)

Page 12: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 16) Create the web page code in test1.html , it is given below.

Here is the code in a more legible font. Make sure its in your test1.html file <html>

<applet code="test1.class" height=200 width=200>

</applet>

</html>

Step 17) Notice the applet tag, its references test1.class not test1.java. When you compile a program, it converts it to a .class file which is made of bytecode which can be read by many browsers thus making java truly cross platform. The height and width are the size of the applet on the webpage. Step 18)To view your java program within eclipse, Click on your file called test1.java to make sure its active in the main window. Then,right click on your test1.java file in the package window, and choose run as>>java applet

Page 13: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 19)The following dialog may show up, select save resources.

Page 14: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

step 20) The applet shows up in a small window called appletviewer. Here is what it looks like!!!

Page 15: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

Step 21) Close the appletviewer window and then open your desktop folder called programming 12. In it, should be a folder called test1, open that folder and the following files should be visible.

Step 22) Now, you can click on the test1 with the internet explorer (or firefox ) icon beside it, and your webbrowser should open up with the applet in it!. If you look at the bottom of the browser window, it should say Applet test1 started.

Page 16: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

YAYYYYYYY. You have made your first applet. Imagine, you can create games, and other useful applications and put them on the net for use by others.

Page 17: Running Eclipse : An example Step 1) Create a folder ...mrkim.2myclass.com/ict11/java/javastarter/running_eclipse.pdf · Step 13)Now you will create a web page to “show” your

If you wanted to create a new applet, you would go into eclipse, create a new project and away you go. So you will end up with many folders in the package view window. Now onto the course itself!!!