To get started: Before we can start programming in Java, there are some programs that you will need to download and set up on your local machine. Java is written in an editor and saved as a .java file. It is then run through a compiler and turned into a .class file, which is then run through the java virtual machine interpreter in order to actually run the program.
First step is to download the Java SE Developers Kit. This can be found here. I decided to download JDK 6 Update 20 with JavaFX SDK but you can choose the option that's best for you.
The next step is to set up java's path. This is optional but it does make it easier to run the programs once you write them. For Windows XP:
- Start -> Control Panel -> System -> Advanced
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
- Close the window.
- Right click "My Computer" icon
- Choose "Properties" from context menu
- Click "Advanced" tab ("Advanced system settings" link in Vista)
- In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
There are lots of other tutorials out there on how to set up java so check them out or look on Sun's Site.
Now that the path is set up, we are almost ready to write our first java program!
The last step is to download some type of editor. I use JEdit because it has nice format highlighting. You can find that here.
Now we are ready to write our first Java program but let's learn a little about how Java works before we write a program.
Rules:
Java is case sensitive - E is not the same as e in java so we need to make sure that we use capitals where necessary and lower case in the right places too.
All class names have to start with a capital - What's a class? Ok, we didnt talk about that yet, but when we do, it's important to remember that the name must start with a capital letter.
Every java program must have a main method - In order for the program to work it must meet certain rules and one of those includes that it must have a main method. We will look at methods soon.
All statements must end with a ; - Yes every statement must end with a ; in order for it to be valid.
File name must match class name - If you class is called Smiles then your file should be called Smiles.java.
And the last thing before getting started on writing a program is to remember that java has to be compiled before it can be run. We will write our first program in the next tutorial but here we will briefly learn how to compile and run it.
First: Write your program and save it (We will do this soon). Let's pretend the name is Smiles.java. Second: Compile your program. We do this by opening the cmd window. Click start than run then type cmd. Or in the search box of later versions of windows just type cmd. You will type the compile command exactly as its written here : javac Smiles.java. If you have any errors in your program, they will show up here, otherwise your program will compile.
Finally: Run your program. We do this in the cmd window still. Type: java Smiles. Your program should now run!
That's the end of this tutorial. In the next tutorial we will learn a little bit more about java and actually write our first program. See you then!
Published by Brandee Teer
I am currently working as a Web Develop and pursuing Bachelor's in Web Development. I also operate my own freelance web design business. I am working on fixing my past mistakes and becoming a person my child... View profile
- Java Compared to Other Computer LanguagesThis article compares the Java programming language to other programming language.
- Java Programming Language Tutorial: From Oak to JavaThis article covers the main points of Java, as a language.
- Data Types in Java LanguageThe java programming language has many built-in data types. These fall into two broad categories: class type and primitive types. Primitive types are simple values, not objects. Class types are used for more complex t...
- Looping Statements in JavaLooping statements in java enables you to execute blocks of statements repeatedly. The JAVA programming language supports three type of loop constructs: for loop, do-while loop & while loop
- Types of Access Modifiers and Ways to Declare Methods in Java Programming for Begi...Java Methods need to be declared within classes. The main method is the primary method that is first run when a java file is executed.
- A Short Introduction to Java Programming Language
- Java Programming Tutorials: The Online Give and Take
- How to Install Java JDK and Set the Environment Variables
- Understanding Java
- How to Declare Integer Variables in Java
- Delorme Street Atlas 2009 - Review
- Beginner Java Programming: How to Read Java Characters



