View Single Post

  #3 (permalink)  
Old 04-21-2006, 07:28 AM
insane insane is offline
Member
 
Join Date: Apr 2006
Posts: 30
insane is on a distinguished road
Writing your first Java application

Like any other language, Java programming starts with writing source code. Source code are instructions that will be followed by the computer. We can create source code using any standard text editor, such as 'notepad' on Windows, or 'vi' on Unix. All Java source code ends in a '.java' extension.

Our first application will be extremely simple - the obligatory "Hello World". If you've never heard of "Hello World" before, its a common programming exercise when learning a new language. This example will display the words "Hello World" when executed.

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

Code : myfirstjavaprog.java

You should type this code out, using your preferred text editor, and save it as 'myfirstjavaprog.java'. Place this file in a directory (for example, "c:\src\") of its own, not your Java installation directory. Its best to keep your tools and source code separate.
Quote:
Java compilers expect the filename to match the class name. Thus the class, myfirstjavaprog, must be saved as myfirstjavaprog.java. If you're using notepad, you'll need to rename if from myfirstjavaprog.java.txt back to myfirstjavaprog.java
Reply With Quote