Tutorial Categories
Tools and Software
Site Search


Advanced Search
Tutorial Options
Popular Tutorials
  1. Photoshop Concept Car Makeover
  2. Photoshop Man Of Fire Part I
  3. Photoshop Man Of Fire Part II
  4. Photoshop Magic Marker Effect
  5. Photoshop Car Makeover Part II
No popular tutorials found.
Popular Authors
  1. Cory Crampton
  2. Daniel Phillips
  3. tanmay goswami
  4. Rails Forum
  5. Brendan Horverson
  6. CodeCrunch Tutorial Bot
  7. PhotoshopBee .com
  8. Jamie Lewis
  9. Nick Cote
  10. Luther Avery
No popular authors found.
 »  CodeCrunch  »  Programming  »  Java Tutorials  »  Java Basics Part 1
Java Basics Part 1
By Lee Labit | Published  06/30/2006 | Java Tutorials | This tutorial viewed 786 times
Java Basics Part 1
Tutorial for Java Beginners

For this tutorial, you will need to have the Java SDK and a text editor called Textpad.
If you don't have Java SDK, then you can download it at http://java.sun.com/j2se/1.4.2/download.html. Click the link that says "Download J2SE SDK".
Textpad can be found at http://www.textpad.com/download/index.html
Note: You must install the Java SDK first before Textpad.

Once you have both programs installed, open up Textpad.
The most basic structure of Java programs is the following code:

public class MyClass
{
    public static void main(String[] args)
    {

    }

}

Type the above code on Textpad and save the above code as MyClass.java
MyClass is the name of your program. You may rename this to anything that you want. However, when you rename it, you will also need to rename your file.
Now, on Textpad, go to Tools, and click Compile Java. Your computer may pause for one second because it is compiling your code. After it compiles, nothing will happen and you should see your code again. This was just a test that Java SDK is correctly installed on your computer.

Now, the real programming begins.
Start off by typing in System.out.println("My output works") inside the "inner curly brackets" like this:

public class MyClass
{
    public static void main(String[] args)
    {
        System.out.println("My output works");
    }

}

Compile it and go to Tools - Run Java Application. You should now see a new window pops out and displays My output works. Try changing "My output works" into anything that you want to type. Compile it again and run it. You should now see a new window displaying the words that you typed.
Note: You must compile your program everytime you change something in your code.





Comments