Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web
Home


Lesson 1 | Lesson 2 | Lesson 3 | Lesson 4 | Lesson 5 | Lesson 6 | Lesson 7 | Lesson 8 | Lesson 9 | Lesson 10
LESSON 1



Everything in written in blue is the real code. So you can type it in and it will work. If it is not, then it might be part of the real code but is not complete.

Now before we begin lets go get JCreator and understand a few terms. Go to this site JCreator.com. There download the freeware edition to whatever drive you want. Then open that dive that you downloaded JCreator to and double click on the icon that saids Setup. Then read the instructions and click next. Then click next again. Then Select the file you would want to install it to, then click next. Then select the Start menu folder in which it will install a shortcut. Then click next. Now check the box if you want the shortcut, and then click next. Now click install. Finally cilck finsh. Now we need to cover some terms. You will here compile a lot. This means it is checking over your code and changing it to something the computor could read. run means that you show what your program does.

Let's begin this lesson with the Hello world application. Open JCreator, and click on the file bar, then new. Then click on Java File, and then click on the tab that saids Workspace. Name it Java, then click on the tab that saids projects and then title it hello.
If you can not support JCreator then use notepad. But you will still want to download the Java at sun's site.
(If You have JCreator then you only need to type in System.out.println("Hello World!");)
Type this in:

class hello {
    public static void main(String[] args) {
         System.out.println("Hello World!") ;
     }
}


Now compile it by pressing the compile button. If you use notepad then save it as hello.java.(Notepad only) Then go to MS-DOS Prompt I won't explain the instructions, but they do tell you how at Java.sun.com.

Here are the definition to the codes: (Don't worry if this sounds confusing)
"class hello {" Think of it as the title of your program
"public static void main(Strings[] args) {" It's like the main part of the program
"System.out.println("Hello World!");" This prints out the message in quotations
"}"These brackets are the closing of a block set by the brackets on top "{ and {"
"}"
Now we need to know what the semicolons(;) means. Everytime when you have a statement that acually does something you will need it.
For example:
System.out.println("hi"); << that needs it because the statement actually does something.
class car { << don't need any ; becuase it it is that class. (this may sound confusing right now)
However, you don't really need to know all this jargon because if you forget it, the compiler will tell you. It should say something along the line. C:\Program Files\Xinox Software\JCreator LE\MyProjects\java\hello\Hello.java:4: ';' expected System.out.println("Hello World!") If it does, go to that line and put that semicolon in.
Type this in:

//This java example is suppose to be wrong
class hello {
     public static void main(String[] args) {
          System.out.println("Hello World!")
     }
}




Now it should of said something like:
--------------------Configuration: JDK version 1.3.1_08 -------------------- C:\Program Files\Xinox Software\JCreator LE\MyProjects\java\hello\Hello.java:4: ';' expected System.out.println("Hello World!")

^ 1 error

Process completed.

If it did try to fix it. Then compile it again and run it.

Alight, the last thing we need to cover in this lesson is comments. Comments are statements that the compiler skips. This means you can write whatever you want in it and nothing will go wrong. The comment symbols are // , /* */ , and /** */
The // comment skips whatever writings that are on the line, for example:

//the compiler will skip this line.
System.out.println("But it won't skip this line.") ;
The next comment is /*, this comments starts with /* and ends with */. This means that anything put in between /* and */ will be skiped. For example:

/*this line will be skiped and so will
this line*/

System.out.println("But not this line.") ;
And the final comment. It is just like the previous one. Open with /** and close with */

Summary:
Wow, that was lesson one. Don't worry if you don't understand a few things. the only thing you are suppose to understand in this lesson was about compiling, running a program, the simple semicolon mistake, and the comments. Thats all, the rest of the stuff here will be understood as the lessons progress.

Copyright ©2004 Java Wave, All rights reserve.